M
mrsckum
I'm trying to make a pivot table that will dynamically hide a section o
its contents based on a boolean operator the user can set. Becaus
this boolean is used in several places, I don't want to require th
user to manually set the visibility parameters for the pivot table.
It seems like the only way to do this effectively is to have th
booleans set by a button, and have the button not only toggle th
boolean, but also change the visibility in the pivot table.
here's the code i've tried:
Sub ToggleButton1_Click()
If ToggleButton1.Caption = "Include" Then 'Check caption, the
change it.
ToggleButton1.Caption = "Exclude"
ToggleButton1.BackColor = 4966415
Else
ToggleButton1.Caption = "Include"
ToggleButton1.BackColor = 16776960
End If
With ActiveSheet.PivotTables("PivotTable1").PivotFields("MODEL2")
'.PivotItems("20_40_60").Visible = bTFE20_40_60
.PivotItems("2").Visible = bTFE2
.PivotItems("3").Visible = bTFE3
.PivotItems("4").Visible = bTFE4
.PivotItems("5").Visible = bTFE5
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
End Sub
Unfortunately, it tells me "Unable to set the Visible property of th
PivotItem class"
That part of the function I took right out of the macro editor (
created a macro to find out the correct function calls, the contents o
the macro work fine until i copy them into this function). I realiz
it's messy to update all the booleans every time, but i just want t
get SOMETHING to work.
I don't know what to do!! help!!
Andr
its contents based on a boolean operator the user can set. Becaus
this boolean is used in several places, I don't want to require th
user to manually set the visibility parameters for the pivot table.
It seems like the only way to do this effectively is to have th
booleans set by a button, and have the button not only toggle th
boolean, but also change the visibility in the pivot table.
here's the code i've tried:
Sub ToggleButton1_Click()
If ToggleButton1.Caption = "Include" Then 'Check caption, the
change it.
ToggleButton1.Caption = "Exclude"
ToggleButton1.BackColor = 4966415
Else
ToggleButton1.Caption = "Include"
ToggleButton1.BackColor = 16776960
End If
With ActiveSheet.PivotTables("PivotTable1").PivotFields("MODEL2")
'.PivotItems("20_40_60").Visible = bTFE20_40_60
.PivotItems("2").Visible = bTFE2
.PivotItems("3").Visible = bTFE3
.PivotItems("4").Visible = bTFE4
.PivotItems("5").Visible = bTFE5
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
End Sub
Unfortunately, it tells me "Unable to set the Visible property of th
PivotItem class"
That part of the function I took right out of the macro editor (
created a macro to find out the correct function calls, the contents o
the macro work fine until i copy them into this function). I realiz
it's messy to update all the booleans every time, but i just want t
get SOMETHING to work.
I don't know what to do!! help!!
Andr