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?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
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.
 
Upvote 0
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
 
Upvote 0
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:)
 
Upvote 0
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:
Upvote 0
Then, maybe the number of Criteria being used in the SUMIFS ?
 
Upvote 0
Using full-column references with other functions is a killer. I agree with your suggestion to use dynamic ranges or tables.
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,548
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top