How to Fix Microsoft Visual Basic Out of Memory Error in Excel for Mac
Question details
Users encounter an out-of-memory error related to Microsoft Visual Basic when trying to run macros or open the VBA editor in Excel for Mac.

- Product
- Excel for Mac
- Device & OS
- macOS
- Scenario
- Opening the VBA editor or executing macro scripts within an Excel workbook.
- Observed behavior
- Excel displays a 'Microsoft Visual Basic out of memory' error message, preventing the user from editing or running their VBA code.
Ensure you have saved all open workbooks and completely quit all running Microsoft Office applications on your Mac before proceeding with the cache removal steps.
Clear the Excel Application Container Cache
Removing potentially corrupted preference and cache files is the most effective way to resolve sudden Visual Basic memory errors on macOS.
macOS stores application caches and settings in a dedicated container folder. If these files become damaged, they can cause Excel's VBA editor to misallocate memory. Resetting this container forces Excel to generate clean, functioning preference files without deleting your personal spreadsheets.
Make sure Microsoft Excel, Word, and PowerPoint are completely closed. You can do this by right-clicking their icons in the Dock and selecting 'Quit'.
Click anywhere on your desktop to activate Finder. Press Command+Shift+G on your keyboard to open the 'Go to Folder' window, type '~/Library/Containers', and press Return.
In the Containers folder, find the folder named 'com.microsoft.Excel' (or 'Microsoft Excel' on newer macOS versions). Drag this folder to your Desktop to keep it as a temporary backup.
Restart your Mac. Once rebooted, open Excel and try accessing the VBA editor again to see if the out-of-memory error is resolved.

Update Microsoft Office to the Latest Version
Updating your software ensures that any known bugs related to VBA memory management on newer macOS versions are patched.
Optimize the VBA Code to Prevent Memory Leaks
If the out-of-memory error only occurs when running a specific macro, the VBA code itself may be inefficient or causing a memory leak.
Experience a Faster, Lighter Spreadsheet Solution with WPS Office
Tired of encountering memory errors and slow performance in Excel for Mac? Switch to WPS Office. It provides robust spreadsheet capabilities, seamless compatibility with Microsoft Excel formats, and a highly efficient environment that runs smoothly without draining your Mac's system resources.
- 1. Download and Install WPS Office: Get the free WPS Office suite for your Mac from the official website and complete the quick installation process.
- 2. Open your Spreadsheet: Launch WPS Spreadsheets and directly open your existing .xlsx or .xlsm files without any conversion.
- 3. Enjoy Stable Performance: Experience faster load times and smoother macro executions thanks to improved memory management.

Frequently Asked Questions
Why does Microsoft Visual Basic run out of memory on my Mac?
This typically happens due to a corrupted Excel preference/cache file on your macOS, outdated Office software, or inefficient macro code that fails to release object variables and causes memory leaks.
Will deleting the 'com.microsoft.Excel' folder delete my saved spreadsheets?
No. Removing or moving the Excel container folder to the Desktop only resets the application's preferences and cache files. Your saved workbooks and personal data remain completely safe and untouched.
How can I check my Mac's memory usage while running a macro?
You can open the 'Activity Monitor' app on your Mac (located in Applications > Utilities) and navigate to the 'Memory' tab. This will show you exactly how much RAM Excel is consuming while your VBA macro runs.
Can I run my Excel VBA macros in WPS Office?
Yes, WPS Office supports VBA macros. You can open your .xlsm files directly in WPS Spreadsheets and run your existing scripts. Because WPS Office is highly optimized, users often experience better memory management.




