03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
I have two pivot tables on the same worksheet, tied to different tables, but both have a "date" column. When I change the date in either tables Report Filter this code does change the page field in the other one, but the data does not refresh. My primary table is PivotTable2, once I can get this working I would hide that report filter in PivotTable1. Can someone help me out here.
Code:
Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
PivotMacro
PivotMacro1
Application.ScreenUpdating = True
End Sub
'==========================================================
Sub PivotMacro()
Dim PT As PivotTable
Set PT = ActiveSheet.PivotTables("PivotTable1")
PT.RefreshTable
End Sub
'==========================================================
Sub PivotMacro1()
Dim PT As PivotTable
Set PT = ActiveSheet.PivotTables("PivotTable2")
PT.RefreshTable
End Sub
'==========================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim PT As PivotTable
Dim NewPage
If Intersect(Target, Range("D10")) Is Nothing And _
Intersect(Target, Range("D30")) Is Nothing Then
Exit Sub
Else
If Not Intersect(Target, Range("D10")) Is Nothing Then
NewPage = Range("D10").Value
End If
If Not Intersect(Target, Range("D30")) Is Nothing Then
NewPage = Range("D30").Value
End If
Application.EnableEvents = False
For Each PT In ActiveSheet.PivotTables
PT.PageFields("date").CurrentPage = NewPage
PT.ManualUpdate = False
PT.ManualUpdate = True
Next PT
Application.EnableEvents = True
End If
End Sub