Here is the situation
I have a pivot table(PivotTabe1) on Worksheet "Graphs", whose purpose is to supply filter Line of Business Filter and control two Pivot Tables (PivotTable2 & PivotTable3) on Worksheet "Data"
When I try and change the Line of Business Filter on the the Graph page I get a "Run-time error '1004': Unable to set the Visible property of the PivotItem class.
The code is below- any help is appreciated it.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim IndexCtr As Double
If Not Intersect(Target, Range("B1")) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
With Worksheets("Data").PivotTables("PivotTable2").PivotFields("Line of Business")
For IndexCtr = 1 To .PivotItems.Count
.PivotItems(IndexCtr).Visible = True
Next IndexCtr
End With
With Worksheets("Data").PivotTables("PivotTable3").PivotFields("Line of Business")
For IndexCtr = 1 To .PivotItems.Count
.PivotItems(IndexCtr).Visible = True
Next IndexCtr
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Line of Business")
For IndexCtr = 1 To .PivotItems.Count
Worksheets("Data").PivotTables("PivotTable2").PivotFields("Line of Business").PivotItems(IndexCtr).Visible = _
.PivotItems(IndexCtr).Visible
Worksheets("Data").PivotTables("PivotTable3").PivotFields("Line of Business").PivotItems(IndexCtr).Visible = _
.PivotItems(IndexCtr).Visible
Next IndexCtr
End With
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Bookmarks