Hello: I have a workbook that has many worksheet. Each worksheet has one pivot.
The datasource for the pivots is a range - pulled from another worksheet in the same workbook.
I have a macro that gets new records from an sql server and appends them to a queryTable for the datasource,
and so I need to re-set the data range for my pivots when this is run.
My code is working; however, it takes 3 min to run. I have 7 worksheets so far. I was wondering if
my code looked most efficient....maybe there's a way to help it to run a bit faster?
thank you for your help,
Proctor
Sub RefreshALLPivotTables()
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
For Each pt In WS.PivotTables
'MsgBox ("pt.name " & pt.Name)
pt.SourceData = Sheets("ShipData").[ShipData!$A$1:$W$1].CurrentRegion.Address(True, True, xlR1C1, True)
'pt.RefreshTable
Next pt
Set pt = Nothing
Next WS
End Sub
Bookmarks