Method 1:
Dim WSheet as WorkSheet, Pivot as PivotTable
For Each WSheet in ThisWorkbook.WorkSheets
For Each Pivot in WSheet.PivotTables
Pivot.RefreshTable
Next
Next
For Each WSheet in ThisWorkbook.WorkSheets
For Each Pivot in WSheet.PivotTables
Pivot.RefreshTable
Next
Next
Method 2:
ThisWorkbook.RefreshAll
Method 3:
Dim ws as WorkSheet
Dim pt as PivotTable
For Each ws In Activeworkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws
Dim pt as PivotTable
For Each ws In Activeworkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws
Method 4:
Activeworkbook.RefreshAll
To refresh single pivot table follow the below method to execute in excel.
Method 5:
Sub Pivot_Table_Macro()
Dim pt As PivotTable
Set pt = ActiveSheet.PivotTables("My_Pivot")
pt.RefreshTable
End Sub
Dim pt As PivotTable
Set pt = ActiveSheet.PivotTables("My_Pivot")
pt.RefreshTable
End Sub