Thank you so much. I had looked for hours trying to figure this out. I modified the code to work with a check box. It worked like a charm
Private Sub CheckBox1_Click()
Application.ScreenUpdating = False
Dim tbl As PivotTable
Set tbl = Sheets("Pivot Table").PivotTables(1)
If Sheets("Pivot Chart").CheckBox1.Value = False Then
With tbl
.PivotFields("Average of Data 1").Orientation = xlHidden
End With
End If
If Sheets("Pivot Chart").CheckBox1.Value = True Then
With tbl
With .PivotFields("Data 1")
.Orientation = xlDataField
.Name = "Average of Data 1"
.Function = xlAverage
End With
End With
End If
Application.ScreenUpdating = True
End Sub
Bookmarks