Sub RefreshPTs()
Dim Wbk As Workbook
Dim Wks As Worksheet
Dim PT As PivotTable
Dim PC As PivotCache
'*****************************
'written by Angelina Teneva
'*****************************
'refresh pivot caches
'useful when you have multiple caches '+ listobjects fed through SQL queries
'and you only want to refresh the pivot tables but not the listobjects
For Each PC In ActiveWorkbook.PivotCaches
PC.Refresh
Next PC
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'refresh all pivot tables in a workbook
For Each Wks In ActiveWorkbook.Worksheets
Wks.Activate
For Each PT In ActiveSheet.PivotTables
PT.RefreshTable
PT.SaveData = True
Next PT
Next Wks
End Sub