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

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
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:eek:ffice:eek:ffice" /><o:p> </o:p>
Thanks
 
Upvote 0

Forum statistics

Threads
1,215,839
Messages
6,127,199
Members
449,368
Latest member
JayHo

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