Excel Out of Memory on Closing

lougs7

New Member
Joined
Oct 9, 2015
Messages
6
Hi guys,

I have a workbook that uses large sets of data ~8000rows and counting, and whenever I close this work book, Excel gives me the "Out of Memory" pop-up, once I click okay it pops up again, and again... The only way to fix it is to close all my workbooks.

> I have Formulas that use Entire Columns like (C:C).
> I also added the macroL

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CutCopyMode = False
End Sub

Still no fix, any way I can fix this?
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

SpillerBD

Well-known Member
Joined
Jul 2, 2014
Messages
2,706
On save, excel calculates. What mode are calculations in?
How many columns in use?
What bit and version of Excel are you using?
And no, its not good practice to reference an entire column. It is better to limit the rows using dynamic ranges or better yet to use Tables/Table Referencing.
 

lougs7

New Member
Joined
Oct 9, 2015
Messages
6
On save, excel calculates. What mode are calculations in?
Automatic

How many columns in use?
This spreadsheet is robust, a solid 50 on different Sheets, some with a lot of data that I keep adding to it, so I use Sumifs and stuff like that with C:C rather than statically using rows, because I am adding data by the thousands, Last row will always change and eventually surpass whatever I put


What bit and version of Excel are you using?
32bit and Excel 2016
 

SpillerBD

Well-known Member
Joined
Jul 2, 2014
Messages
2,706
This spreadsheet is robust, a solid 50 on different Sheets, some with a lot of data that I keep adding to it, so I use Sumifs and stuff like that with C:C rather than statically using rows, because I am adding data by the thousands, Last row will always change and eventually surpass whatever I put

32bit and Excel 2016
SUMIFS is an array function and using an array on 1.04 million rows, when most are empty, is a waste. You should use a Table. Also, you are memory bound using 32-bit. Even more so if your OS is 32-bit, and you must be aware of what functions are memory hogs. Array functions are and the more cells with array functions, the more memory will be used. PivotTables do a far better job, though they commit more on the front-end.

Convert your range to a Table using CTRL+T and then redo your formulas. You should get the TableName[FieldName] referencing.
The Table referencing will capture all the rows in the Table and adding data to Table automatically extends the Table.

Robust... my source data files are generally between 100,000 - 500,000 rows:)
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,736
Office Version
2010
Platform
Windows
SUMIFS is an array function and using an array on 1.04 million rows, when most are empty, is a waste.
All of the xxxIF and xxxIFS function require range arguments, and they are automatically truncated to the used range of the worksheet, so using full-column references doesn't affect performance.
 
Last edited:

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,736
Office Version
2010
Platform
Windows
Using full-column references with other functions is a killer. I agree with your suggestion to use dynamic ranges or tables.
 

lougs7

New Member
Joined
Oct 9, 2015
Messages
6
Thanks guys I will; try this out.

The thing is I am using macros, through code I located the last row and add all my add to the line below that. Can my macro add data within the table? I don't want the data to be place below (outside) the table.... Let me know if so I will do the conversion
 

SpillerBD

Well-known Member
Joined
Jul 2, 2014
Messages
2,706
I'm not entirely sure, though if the Table doesn't make that assumption/auto-extension when working with a Table, then the macro could have a few lines to redefine the range that makes up the table. I do believe the Table will extend.

My problem, sort of, is that I have gotten away from such techniques and append all my data through PowerQuery/Get and Transform. With O365, we finally see these tools available to everyone, not just Professional ProPlus versions. I'm also not working with long term appends.

Also I remembered why I really don't like the full column referencing. While shq in #5 of this thread points out, Excel looks only to the last used row, I've had some workbooks with strange errors or from others users that just didn't follow the same rules I would. Had a corrupt workbook that the last used row was the last row. Rare, odd... yeah, but a lesson learned and easily defended against.
 

Forum statistics

Threads
1,089,432
Messages
5,408,187
Members
403,188
Latest member
Sanjana Ramesh

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top