Runtime Error 7: Out of Memory [Fix]

Get rid of your temporary files to create space

Reading time icon 5 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

Key notes

  • Runtime error 7 out of memory message indicates that your computer is out of memory.
  • This can occur when you have a large number of programs running at the same time or when you have too many files open. 
  • The first thing to do is to close some programs or quit those that are open in the background.

Runtime error 7 out of memory is a common error every programmer faces at least once in a lifetime. Other computer users are also not exempt from this error, as it appeared when using Microsoft Excel.

You might get this error if you’re working on large projects using too much memory. A run repair tool should suffice, but even such requires memory to be installed, which is a memory issue. If a repair tool is out of the picture, find other ways to deal with this error.

What is the run time error 7 in Excel?

Run time error 7 is common in Excel. It occurs when the program runs out of memory. This can happen if you work with a large spreadsheet or have many spreadsheets open simultaneously.

It may also occur when you try to run a macro you have written, but when you execute it, it fails because your system lacks sufficient resources.

Other reasons you may encounter the runtime error 7 out of memory include:

  • Corrupt file – Sometimes, when you open an Excel file, it may not open properly because it has become corrupt for some reason.
  • Insufficient memory – Your computer needs enough space to store files and ensure that all applications run smoothly without interruptions or crashes due to insufficient memory resources.
  • Compatibility issues – Another common cause of this error is an incompatibility between the version of Excel you are using and the version of the file you are trying to open.
  • Unexpected closure of a workbook – You may also get this error if you close an Excel workbook without saving changes. When this happens, Excel tries to run the macro using objects that no longer exist.
  • Memory leak – A memory leak occurs when a program allocates memory from the system and fails to free or reuse it. If you have an Excel file with a large number of formulas and functions, it’s possible that there is a memory leak.
  • Hardware failure – The problem may also be caused by an issue with your computer’s hardware. Your CPU might be failing and causing this error.

Strangely enough, one of our readers encountered this error when one of the cells in the spreadsheet had an apostrophe (King’s Lynn). Removing the character returned everything to normal.

How can I fix the runtime error 7 out of memory?

Start off with these basic workarounds before jumping onto the heavy hitters:

1. Defragment your hard disk drive

Note icon NOTE
Perform this step only if you have an HDD. For SSD, this procedure is simply useless.
  1. Right-click on the Start Menu to bring up the shortcut menu, then select Windows Terminal (Admin).
  2. Type the following command, then hit Enter to analyze your drive. Remember to replace X with the letter of your drive: defrag X: /a
  3. After the scan is finished, you’ll see information about your hard drive, including the fragmentation level and a note saying whether you need to defragment your drive or not.
  4. Now enter the following command to defrag that drive: defrag X:
  5. Wait for the process to finish.

2. Increase Virtual Memory

  1. Hit the Search icon on the Taskbar, type View advanced system settings in the text field at the top, and click on the relevant search result that appears.View advanced system settings to increase virtual memory windows 11
  2. In the Advanced tab, click on the Settings button under Performance.Settings advanced
  3. Navigate to the Advanced tab in the Performance Options window.Advanced to increase virtual memory in Windows 11
  4. Next, click on Change under Virtual memory.Change virtual memory
  5. Untick the checkbox for Automatically manage paging file size for all drives.Untick checkbox to to increase virtual memory in Windows 11
  6. If Windows was managing the virtual memory earlier, it’s best to clear the previously set value and then increase it.
  7. To do that, click on the drive with System managed listed, select No paging file, and click on Set.No paging file
  8. Click Yes on the confirmation prompt that pops up.Click Yes
  9. Now, choose a drive or partition from the list, select the Custom size option and enter the same value under Initial size and Maximum size fields in MB (1GB=1024MB), taking cue from the previous section.Enter values to to increase virtual memory in Windows 11
  10. Once done, click on Set and then on OK at the bottom to save the changes.Click Set to to increase virtual memory in Windows 11
  11. Next, restart the computer for the changes to come into effect.

Should the above steps fail to yield the expected results for runtime error 7 out of memory, upgrading your RAM would be next.

But before you’re quick to get a new one, do your due diligence first. Sometimes, you may find that Windows is not using all RAM or even with two RAM sticks, only one RAM slot is working.

Exhaust all avenues before replacing any components of your PC. We all know nothing comes cheap.

That’s it for this article, but if you have any other solution worth mentioning, let us know in the comment section below.

More about the topics: Microsoft Excel, Runtime Errors