ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel PivotChart Field Buttons (https://www.excelbanter.com/excel-programming/412891-excel-pivotchart-field-buttons.html)

gmead7

Excel PivotChart Field Buttons
 
I am using Excel 2003. I have a PivotChart with 3 Field Buttons. I want the
user to be able to work with one of the field buttons and I want disable (and
preferably make invisible) the other 2 field buttons. I suspect I may have
to do this through VBA, but haven't been able to find a way to do this yet.
I haven't been able to figure out how to reference the field buttons within
VBA either. I am pre-novice in regards to VBA so I really need the "for
dummies" version (please, be gentle).

TomPl

Excel PivotChart Field Buttons
 
You can disable the field button on a pivot chart by disabling
the itemselection property of the field in the underlying
pivot table. This can be accomplished with code similar to
what follows.


Hiding the button on the pivot chart is a different matter.
I don't know how to hide one button without hiding all.


Sub DisablePivotField()

Dim wks As String
Dim pvt As String
Dim fld As String

wks = "2007Pivot"
pvt = "PivotTable2"
fld = "BusUnit"

Worksheets(wks).PivotTables(pvt).PivotFields(fld). EnableItemSelection = False

End Sub

Luck to you.

"gmead7" wrote:

I am using Excel 2003. I have a PivotChart with 3 Field Buttons. I want the
user to be able to work with one of the field buttons and I want disable (and
preferably make invisible) the other 2 field buttons. I suspect I may have
to do this through VBA, but haven't been able to find a way to do this yet.
I haven't been able to figure out how to reference the field buttons within
VBA either. I am pre-novice in regards to VBA so I really need the "for
dummies" version (please, be gentle).


gmead7

Excel PivotChart Field Buttons
 
Thanks Tom - this was very helpful.

"TomPl" wrote:

You can disable the field button on a pivot chart by disabling
the itemselection property of the field in the underlying
pivot table. This can be accomplished with code similar to
what follows.


Hiding the button on the pivot chart is a different matter.
I don't know how to hide one button without hiding all.


Sub DisablePivotField()

Dim wks As String
Dim pvt As String
Dim fld As String

wks = "2007Pivot"
pvt = "PivotTable2"
fld = "BusUnit"

Worksheets(wks).PivotTables(pvt).PivotFields(fld). EnableItemSelection = False

End Sub

Luck to you.

"gmead7" wrote:

I am using Excel 2003. I have a PivotChart with 3 Field Buttons. I want the
user to be able to work with one of the field buttons and I want disable (and
preferably make invisible) the other 2 field buttons. I suspect I may have
to do this through VBA, but haven't been able to find a way to do this yet.
I haven't been able to figure out how to reference the field buttons within
VBA either. I am pre-novice in regards to VBA so I really need the "for
dummies" version (please, be gentle).



All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com