Pivot Tables

  • Thread starter Thread starter jc
  • Start date Start date
J

jc

I have multiple pivot tables which are linked to data I
import into the Excel file. I would like to use "For each
next" code to update all of the pivot tables in the file
so I don't have to know the names of the pivot tables. I
I use "for each next" for a lot of objects in Excel, but
haven't had any luck with the code for a pivot table.

Thanks, jc
 
The following code will refresh all pivot tables in the active workbook:

'============================
Sub RefreshAllPivots()
Dim ws As Worksheet
Dim pt As PivotTable

On Error Resume Next
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next
Next
End Sub
'==========================
 
Back
Top