Just to share the info (if already known, sorry
)
I recently found a way to hide calculated fields from a pivot table via VBA
Previously the obvious instruction :
Set pt = ActiveSheet.PivotTables("mypivottable")
pt.pivotfields("my calculated field").Orientation = xlHidden
or
pt.CalculatedFields.Orientation = xlHidden
generated an error... And impossible to find a "simple" solution on the net.
ButI finally found this (Excel 2010).
This hide/remove all datafields and all calculated fields set in a pivot table, like it would be done manually
Hope this could helps someone.
I recently found a way to hide calculated fields from a pivot table via VBA
Previously the obvious instruction :
Set pt = ActiveSheet.PivotTables("mypivottable")
pt.pivotfields("my calculated field").Orientation = xlHidden
or
pt.CalculatedFields.Orientation = xlHidden
generated an error... And impossible to find a "simple" solution on the net.
ButI finally found this (Excel 2010).
Set pt = ActiveSheet.PivotTables("mypivottable")
For Each pi In pt.DataPivotField.PivotItems
pi.Visible = False
Next
For Each pi In pt.DataPivotField.PivotItems
pi.Visible = False
Next
This hide/remove all datafields and all calculated fields set in a pivot table, like it would be done manually
Hope this could helps someone.