Forum Discussion
Pierre Gerrits
Feb 09, 2017Copper Contributor
Create a button to refresh pivot tables in a file
I have a large data query file with a few sheets containing pivot tables. I need to add a button to the first sheet that will refresh all the pivot tables in the file.
Wyn Hopkins
Feb 10, 2017MVP
HI Pierre
If you do want to go down the Macro route rather than using the Refresh All button then I'd suggest adding this code to a module.
Best to avoid any hard coded referencing to Pivot Table names or sheets etc.
Sub RefreshAllPivots()
Dim pc As PivotCache
For Each pc In ThisWorkbook.PivotCaches
pc.Refresh
Next pc
End Sub