For a certain field in my pivot table (lets call it field1) I want to show only choices 1-5 and remove blanks and anything else that pops up. The problem is, there are a lot of other things that could be in field1, so it's not has easy as turning off the visibility for blanks. Also, there might not be 1-5 every time.
How would I change this code to turn visibility for all other choices to false and not crash if say there is no 2.
Sheets("Com").Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Field1")
.PivotItems("1").Visible = True
.PivotItems("2").Visible = True
.PivotItems("3").Visible = True
.PivotItems("4").Visible = True
.PivotItems("5").Visible = True
How would I change this code to turn visibility for all other choices to false and not crash if say there is no 2.
Sheets("Com").Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Field1")
.PivotItems("1").Visible = True
.PivotItems("2").Visible = True
.PivotItems("3").Visible = True
.PivotItems("4").Visible = True
.PivotItems("5").Visible = True