Hi,
I have a data model which I use to create a pivot table. I am using multiple measures in the same pivot table ($'s and %'s).
The one of interest can be referenced in my code as such: "ActiveSheet.PivotTables("PivotTable2").CubeFields("[Measures].[YTD % Chg (DS)]")."
I need a code to automatically change the number format of that measure to "0%;[Red]-0%" in my pivot table.
This needs to be in VBA because I created buttons that allow report users to toggle from one product sales info to another. I want the % chg year over year to formatted every time the pivot table is changed.
When I use the macro recorder, the following code is generated, but it doesn't work when I try to run it. I don't understand why.
Could you please help? Any guidance would be appreciated.
Thank you.
I have a data model which I use to create a pivot table. I am using multiple measures in the same pivot table ($'s and %'s).
The one of interest can be referenced in my code as such: "ActiveSheet.PivotTables("PivotTable2").CubeFields("[Measures].[YTD % Chg (DS)]")."
I need a code to automatically change the number format of that measure to "0%;[Red]-0%" in my pivot table.
This needs to be in VBA because I created buttons that allow report users to toggle from one product sales info to another. I want the % chg year over year to formatted every time the pivot table is changed.
When I use the macro recorder, the following code is generated, but it doesn't work when I try to run it. I don't understand why.
VBA Code:
With ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Sell Out].[Chain Category].[Chain Category]")
PivotItems().Visible = "0%;[Red]-0%"
End With
End Sub
Could you please help? Any guidance would be appreciated.
Thank you.