MagicalHippo
Board Regular
- Joined
- Oct 13, 2015
- Messages
- 122
Really confused here. I have a Pivot table and using VBA to hide specific fields. It works, however, when it gets to the commented code it stops and throws the "unable to get pivot field property class". I can comment out this segement of code, it will run through the 100 other Pivot Fields inside of "Cost Centre" but then freeze and throw another area for another .PivotItem field within "Cost Centre". I'm confused as to what is going on....First I thought it was due to having no fields selected, as you cannot have everything set to "False", So I set my fields to true at the beginning, but that didn't resolve anything
Code:
ws3.PivotTables("PivotTable2").PivotFields("Cost Centre #"). _
CurrentPage = "(All)"
With ws3.PivotTables("PivotTable2").PivotFields("Cost Centre #")
.PivotItems("430813").Visible = True
.PivotItems("430829").Visible = True
.PivotItems("0").Visible = False
' .PivotItems("182249").Visible = False
.PivotItems("182833").Visible = False
.PivotItems("182841").Visible = False
.PivotItems("182895").Visible = False