On Excel File Closing - Receive Out of Memory Warning and Closing of Application

%3CLINGO-SUB%20id%3D%22lingo-sub-973242%22%20slang%3D%22en-US%22%3EOn%20Excel%20File%20Closing%20-%20Receive%20Out%20of%20Memory%20Warning%20and%20Closing%20of%20Application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-973242%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20reasonably%20large%20file%20with%20VBA%20code%20and%20Userforms.%20Frequently%2C%20upon%20closing%20this%20file%20I%20receive%20the%20error%20%22Microsoft%20Visual%20Basic%20for%20Applications%20-%20Out%20of%20memory%22.%20Once%20I%20have%20closed%20the%20error%20message%20the%20entire%20Excel%20application%20and%20all%20open%20workbooks%20are%20shutdown%20and%20Excel%20restarts.%20The%20problem%20seems%20to%20occur%20most%20often%20when%20I%20have%20been%20in%20the%20VB%20editor%20but%20I%20cannot%20say%20that%20it%20only%20happens%20then.%20This%20issue%20happens%20even%20after%20I%20have%20cleared%20the%20clipboard%20(which%20I%20have%20never%20had%20to%20do%20before%20for%20any%20other%20file).%20I%20have%20rebuilt%20the%20file.%2C%20I%20changed%20Excel%20to%20have%20Admin%20rights%20but%20that%20screwed%20up%20other%20things%20and%20had%20to%20have%20MS%20fix%20that.%26nbsp%3B%20%26nbsp%3BHelp!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-973242%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-978252%22%20slang%3D%22en-US%22%3ERe%3A%20On%20Excel%20File%20Closing%20-%20Receive%20Out%20of%20Memory%20Warning%20and%20Closing%20of%20Application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-978252%22%20slang%3D%22en-US%22%3EAny%20User%20Defined%20FUnctions%20called%20from%20cells%20in%20your%20file%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2121889%22%20slang%3D%22en-US%22%3ERe%3A%20On%20Excel%20File%20Closing%20-%20Receive%20Out%20of%20Memory%20Warning%20and%20Closing%20of%20Application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2121889%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F22322%22%20target%3D%22_blank%22%3E%40Jan%20Karel%20Pieterse%3C%2FA%3E%26nbsp%3BThank%20you%20for%20asking%20this%20question%20Jan%20Karel.%20I%20am%20experiencing%20the%20same%20issue%20and%20I%20do%20indeed%20have%20user%20defined%20functions%20from%20cells%20in%20my%20file.%20Specifically%3A%3C%2FP%3E%3CP%3Ea%20generic%20public%20function%3A%20UserName%20%3D%20ENVIRON(%22UserName%22)%20and%26nbsp%3B%26nbsp%3Banother%20UserAccess%20%3D%20Application.WorksheetFunction.Vlookup(UserName%2CtblUserRange%2C2%2C0).%3C%2FP%3E%3CP%3ECould%20this%20be%20a%20potential%20source%20of%20error%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

I have a reasonably large file with VBA code and Userforms. Frequently, upon closing this file I receive the error "Microsoft Visual Basic for Applications - Out of memory". Once I have closed the error message the entire Excel application and all open workbooks are shutdown and Excel restarts. The problem seems to occur most often when I have been in the VB editor but I cannot say that it only happens then. This issue happens even after I have cleared the clipboard (which I have never had to do before for any other file). I have rebuilt the file., I changed Excel to have Admin rights but that screwed up other things and had to have MS fix that.   Help!

2 Replies
Any User Defined FUnctions called from cells in your file?

@Jan Karel Pieterse Thank you for asking this question Jan Karel. I am experiencing the same issue and I do indeed have user defined functions from cells in my file. Specifically:

a generic public function: UserName = ENVIRON("UserName") and  another UserAccess = Application.WorksheetFunction.Vlookup(UserName,tblUserRange,2,0).

Could this be a potential source of error?