[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Updating pivot tables in a workbook

Posted on 2009-05-12
4
Medium Priority
?
620 Views
Last Modified: 2012-05-06
Whenever I run the macro below more than once I get this error message: "Excel cannot complete this task with available resources. Choose less data or close other applications." And then I get a VBA error message that says, "Run-time error '5': Invalid procedure call or argument."

I need to apply a macro that updates pivot table ranges across an entire workbook, my first attempt at this was to make one macro but I got the error message above. What I did then was to split the macro into three pieces. I run one macro and then it would update the pivot tables in sheets: "Center", "Sony", "Howard", and "Conference". Then i would run another macro that would do it in the sheets after that, etc. I can update the first set of sheets but when I try and run the second maco half way through I get the error message that I got above.


Public Sub UpdAllPivots()
  Dim shtThing As Worksheet
  Dim pvtThing As PivotTable
  For Each shtThing In Application.Sheets
  If shtThing.Name = "Center" Or shtThing.Name = "Sony" Or shtThing.Name = "Howard" Or shtThing.Name = "Conference" Then
    For Each pvtThing In shtThing.PivotTables
      pvtThing.ChangePivotCache ActiveWorkbook. _
        PivotCaches.Create(SourceType:=xlDatabase, _
        SourceData:="C:\Documents and Settings\shahryarm\Desktop\[Combined 09S 20090407v8.xlsm]Combined Grantee Main Data!R3C4:R50000C252", _
        Version:=xlPivotTableVersion12)
    Next
    End If
  Next
End Sub

Open in new window

0
Comment
Question by:hermes829
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Jerry Paladino
ID: 24400487
Hermes829,
Have you tried this with a smaller dataset?  Your 50,000 rows and 252 columns is 12,600,000 cells of data.  Each Pivot Table by default holds a copy of the data so you could truly be running out of resources.  If you have 10+ pivot tables it may be too much without setting PT options to disable "Save source data with file".  If the dataset does not truly have 50,000 rows and you used that number to make sure you catch the bottom of the data then perhaps you can use a dynamic range name to define the data area.  
Some sample code is here - http://www.experts-exchange.com/Q_24173598.html but it is very similar to what you have so I don't expect it to resolve the problems you are having.  I would start with reducing the data to 500 rows and 15 columns just to work out any issues with the VBA and try to pinpoint the root cause of the problem.
HTH,
Jerry
0
 

Author Comment

by:hermes829
ID: 24424358
Thanks I'm afraid that the dataset is the size it is. We just have too many pivot tables referencing a dataset that's too big to continue using this type of format. Do you have any suggestions for database programs to switch to?
0
 
LVL 16

Accepted Solution

by:
Jerry Paladino earned 2000 total points
ID: 24424585
Yes, I use MS-Access and its query engine to summarize large dataset.   With Excel Pivot Table you can use "External Data" and point them to an Access query as the datasource.   Do the majority of your summarization in Access and then report with your Excel Pivot Tables.    You can drastically reduce the size of the dataset that are stored with the pivot tables this way.
Another option is to use Excel's built in tool MS-Query to pull the Access query results into an excel sheet and then base your pivot table on that summarized sheet.  Several options.
HTH,
Jerry
0
 

Author Closing Comment

by:hermes829
ID: 31580604
Awesome thank you very much for this information.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question