In another post I was provided with the following VBA code to attach to a "Refresh" button to refresh Pivot data:
Option Explicit
Sub Button5_Click()
Dim PvtTbl As PivotTable
Dim PvtCache As PivotCache
Dim PvtDataRng As Range
' Set/Update Pivot Data Range
Set PvtDataRng = Worksheets("PivotDataSheet").Range("A1:E100") ' <-- just an example
' Create/Update Pivot Cache
Set PvtCache = ActiveWorkbook.PivotCaches.Add(xlDatabase, PvtDataRng)
' Set the Pivot Table (already created, otherwise need to create it)
Set PvtTbl = Worksheets("DD").PivotTables("test")
' refresh the Pivot Table with the latest Pivot Cache
With PvtTbl
.ChangePivotCache PvtCache
.RefreshTable
End With
End Sub
How can this code be modified to simultaneously refresh a 2nd pivot in the same worksheet? Lets call this 2nd pivot "test2" and it is also in the DD worksheet.
Thanks, Kevbo