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

memorymicrosoft excelmicrosoft-excel-2007resourcesvba

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.

Best Answer

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

Related Question