I am struggling to understand why the folllowing code doesn't update the pivot table based on a checkbox from another sheet. The first part of the code works perfectly but the second part doesn't update the pivot table. Can you assist, please?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim pt As PivotTable
If Sheets("MAIN").DrawingObjects("CheckBox58").Value = True Then
Set pt = Sheets("child2").PivotTables("PivotTableCHILD2")
pt.PivotFields("TeamName").PivotItems("item_name").Visible = True
Set pt = Nothing
End If
If Sheets("MAIN").DrawingObjects("CheckBox58").Value = False Then
Set pt = Sheets("child2").PivotTables("PivotTableCHILD2")
pt.PivotFields("TeamName").PivotItems("item_name").Visible = False
Set pt = Nothing
End If
Private Sub Worksheet_Change(ByVal Target As Range)
Dim pt As PivotTable
If Sheets("MAIN").DrawingObjects("CheckBox58").Value = True Then
Set pt = Sheets("child2").PivotTables("PivotTableCHILD2")
pt.PivotFields("TeamName").PivotItems("item_name").Visible = True
Set pt = Nothing
End If
If Sheets("MAIN").DrawingObjects("CheckBox58").Value = False Then
Set pt = Sheets("child2").PivotTables("PivotTableCHILD2")
pt.PivotFields("TeamName").PivotItems("item_name").Visible = False
Set pt = Nothing
End If