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?
ActiveWorkbook.RefreshAll
refreshes everything, not only the pivot tables but also the ODBC queries. I have a couple of VBA queries that refer to Data connections and using this option crashes as the command runs the Data connections without the detail supplied from the VBA
I recommend the option if you only want the pivots refreshed
Sub RefreshPivotTables()
Dim pivotTable As PivotTable
For Each pivotTable In ActiveSheet.PivotTables
pivotTable.RefreshTable
Next
End Sub