Refresh All Pivot Tables

tetsujinbh

New Member
Joined
May 1, 2014
Messages
2
Hi

I have a workbook with a lot of pivot tables. The workbook is also connected to an external database. Whenever I open the workbook, it automatically updates the data, but not the pivots. I know you can set the pivots up to refresh on opening, but it refreshes the pivots before it updates the data so it is pretty pointless. Refresh All does the same thing. So I just want to refresh the pivots and not the data, if that makes sense? I tried using code that people suggested on forums:

Dim Sheet as WorkSheet, Pivot as PivotTable
For Each Sheet in ThisWorkbook.WorkSheets
For Each Pivot in Sheet.PivotTables
Pivot.RefreshTable Pivot.Update
Next
Next
however, it just seems to loop continuously and I had to force excel to close in order to stop it.
Is there a way to refresh just the pivots without the loop?
thanks.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,216,500
Messages
6,131,016
Members
449,615
Latest member
Nic0la

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