4

I received the error message "Excel ran out of resources while attempting to calculate one or more formulas" on ONE of my computers (Out of 2).

My worksheet contains: (Inside a single worksheet, not workbook, there are formulas in another worksheet)

  • 1,000,000 formulas

  • a Pivot table base on 900,000 rows of data

When I run excel/vba on the action "Calculate Sheet" (The current worksheet only), the program would pop the following error message:

Excel ran out of resources while attempting to calculate one or more formulas

on neither I "refresh" a pivot table in (Excel or VBA) or "Calculate Sheet" in (Excel or VBA)

I have 2 computers:

  • both running 64 bits Windows 7,

  • both running Excel 2007 32Bit,

  • I run Excel right after starting Windows,

  • my development PC with 2GB RAM can run without problem,

  • another PC with 6GB RAM shown the ran out of resources error message

  • Running on same set of data, same excel file

I also notice that on my development PC, it is using ~ 1.2G RAM, and the non-working PC, it is using 900M RAM prior to clicking the "Refresh"/"Calculate" Action.

EDIT

The Non-working Computer can handle data within 100,000 rows of data

My questions:

  1. Why it is working for the computer with less memory but not the one with more memory? (main question)
  2. What can I do to reduce the memory used by Excel? (sub question) (Other than deleting data)

Any help is appreciated, please point me into the right direction or simply give some clue.

EDIT:I am thinking of removing the formulas, and move the logic into vba, and do it by caching the data maybe per 10,000 rows. But this won't solve my problem if "refresh" pivot table would show the same error.

Larry
  • 179

6 Answers6

3

The reason is probably differing 32-bit memory fragmentation on the 2 Pcs (its often difficult to use all of the theoretically available 2 GB).
You can reduce the amount of memory used by the pivot table by reducing the number of columns and/or reducing the memory required by some of the columns (text strings are a good candidate).
(You can measure the amount of memory used by the pivot cache with VBA PivotCache.memoryUsed)
I assume you are creating the pivot cache by reading the data from the query directly into the pivot cache rather than putting the query data onto a worksheet and basing the the pivot on the worksheet, which would use much more memory.
You don't say what the >1000000 formulas are so I don't have any suggestions for improvement for them.
If you want to use large amounts of data in Excel pivots etc you would get better results from the 64-bit version of Excel 2010 which does not have the 2-GB limit

2

thanks for all the suggestion, readings and help. I have solved the problem by

  1. Change all formulas into values step by step per ~ 100,000 rows --- This reduce the memory held by excel by 10%
  2. Removed any unnecessary data/Worksheet(s) in the workbook (The raw data before data massaging ) --- This reduce the memory held by excel by 40%

And the reading http://www.add-ins.com/support/out-of-memory-or-not-enough-resource-problem-with-microsoft-excel.htm suggest why 6G RAM PC is facing this issue rather than 2G RAM PC. I think it's because the 6G PC has a lot of excel add-in on it consuming RAM as well.

Thanks for the helps.

Larry
  • 179
1

It looks like you construct very large Excel sheets. 32-bit applications can only use up to 2GB of RAM, unless they can be configured to use up to 3.2GB with a special "switch". So Excel 32-bit is actually running out of memory after 2GB.

So it doesn't matter if you have 16 or 32GB RAM even. You need 64-bit MS Office so that it will be free to use RAM above 2GB. Only then will your extra RAM of 6GB be actually useful to Excel. Otherwise, it is stuck with having to figure out how to run with only 2GB of RAM, and most likely, will start using the pagefile on the hard drive.

One possibility would be to increase the size of the Windows page file. I never let windows manage the pagefile. I set it to 1.5X physical RAM and set minimum and maximum pagefile size THE SAME. This prevents RAM fragmentation. So if you have 4GB of RAM, set it to 6144 / 6144MB min/max.

Byrna5
  • 60
  • 3
1

The answer is to upgrade to a 64-bit version of Excel. It can address a much larger memory range, and is also just generally much faster and the right tool for the job if you have a big spreadsheet.

1

old queston but still valid for all the versions, I run into similar issues when the formulas I used had too big scope even though most of the fields were empty, ex: DO_CALCULATION(D1:D100000) will take significant amount of time and memory even if only cells D1:D10 have any value. So be careful trying to make formulas ready for data expansion, keep the ranges small :)

mikus
  • 221
  • 2
  • 3
0

One possible reason why it might run out of resources on a 6GB machine, and not a 2GB machine, is that Windows itself takes more resources to manage 6GB of memory than it does to manage 2GB of memory.

It was a known problem in 32 bit Windows (and an even bigger problem in 16 bit Windows). It is supposed to be solved on 64bit systems, but...

In any case, it's possible to test: disable the extra RAM and see if the problem goes away.

user165568
  • 926
  • 5
  • 16