Private Sub Worksheet_Activate()
Dim PTRange As Range
‘Reset the data source and refresh.
Set PTRange = Sheets(“Sheet1“).Range(“A1“).CurrentRegion
ActiveSheet.PivotTables(“PivotTable2)”).ChangePivotCache _
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, _
SourceData:=PTRange)
ActiveSheet.PivotTables(“PivotTable2“).PivotCache.Refresh
End Sub