Refreshing all the pivot tables in my excel workbook with a macro

Lipis picture Lipis · Sep 16, 2008 · Viewed 537.2k times · Source

I have a workbook with 20 different pivot tables. Is there any easy way to find all the pivot tables and refresh them in VBA?

Answer

GSerg picture GSerg · Sep 16, 2008

Yes.

ThisWorkbook.RefreshAll

Or, if your Excel version is old enough,

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