Refreshes all pivot tables in VBA

schappelljr

Board Regular
Joined
Feb 2, 2009
Messages
55
I have built a spreadsheet with 24 pivot tables. I trying to write a Macro that will refreshes the all of the pivot tables. I am doing them 1 at a time in VBA. But is there a refresh all command in VBA? Right now it is taking the PC too long.


this is what i have so far


ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable9").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable10").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable4").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable11").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable12").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable5").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable13").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable14").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable15").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable7").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable16").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable17").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable18").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable27").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable19").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable20").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable21").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable29").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable30").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable31").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable32").PivotCache.Refresh
Sheets("Mcap Data").Select
Range("A2:C2").Select
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
How about the crazily named RefreshAll method?

Should refresh everything but I don't know if it'll make any difference to the performance.:)
Code:
ThisWorkbook.RefreshAll
 
Upvote 0
The one-line works the best. It took 14 sec the old way and 1 sec the new way.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Thanks
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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