Excel vba: error hiding calculated field in Pivot table
Posted
by Patrick Honorez
on Stack Overflow
See other posts from Stack Overflow
or by Patrick Honorez
Published on 2009-09-07T08:38:58Z
Indexed on
2010/04/17
21:13 UTC
Read the original article
Hit count: 237
I have written several Subs to show/hide fields in a PivotTable. Now I am trying to do the same with a calculated field, but I get an error when hiding it. I took my code from the recorder and the recorder's code also halts on the last line. I googled the error message, without serious result.
Sub PrRemove()
'remove PR
Dim pt As PivotTable
Set pt = ActiveSheet.PivotTables("MyPivot")
pt.PivotFields("MyField").Orientation = xlHidden '<- here is the error
End Sub
The same code works fine if MyField is a normal field (not a calculated one).
I am using Excel 2007 with SP2.
Any clue ?
© Stack Overflow or respective owner