I am working on a VBA for a pivot table. I have several items that I wan to deselect, which I have figure out how to do. I will be running this multiple times a month the data will be changing each time. I have a set list of items that I want deselected, i am getting an error
"Run-time error '1004': Unable to get the PivotItems property of the PivotField class"
when deselected item is not in the data set. How can i resolve this. Below is sample code, the last line is currently erroring.
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Object")
.PivotItems("0113").Visible = False
.PivotItems("0120").Visible = False
.PivotItems("0131").Visible = False
.PivotItems("0140").Visible = False
.PivotItems("0150").Visible = False
.PivotItems("0291").Visible = False
"Run-time error '1004': Unable to get the PivotItems property of the PivotField class"
when deselected item is not in the data set. How can i resolve this. Below is sample code, the last line is currently erroring.
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Object")
.PivotItems("0113").Visible = False
.PivotItems("0120").Visible = False
.PivotItems("0131").Visible = False
.PivotItems("0140").Visible = False
.PivotItems("0150").Visible = False
.PivotItems("0291").Visible = False