Private Sub Worksheet_Activate()
Dim PTRange As Range
Set PTRange = Sheets("Sheet1").Range("A1").CurrentRegion
ActiveSheet.PivotTables("PivotTable2").ChangePivotCache
ActiveWorkbook.PivotCaches.Create _ (SourceType:=xlDatabase, SourceData:= _
PTRange, Version:=xlPivotTableVersion10)
'Refresh PT.
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
End Sub
Dim PTRange As Range
Set PTRange = Sheets("Sheet1").Range("A1").CurrentRegion
ActiveSheet.PivotTables("PivotTable2").ChangePivotCache
ActiveWorkbook.PivotCaches.Create _ (SourceType:=xlDatabase, SourceData:= _
PTRange, Version:=xlPivotTableVersion10)
'Refresh PT.
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
End Sub