Hi,
I've written the following code for my pivot table. The Pivot Items. visible= "false" I do not want showing on my report. I only want the 4 items that equal True. Everything was working but this month, one of the Asset Types "B412D"
was not in my data so it crashed on line .PivotItems("B412D").Visible = False
Is there a better way to write this code to avoid it crashing when it does not find the Asset Type in the data being used? I have little VBA experience.
'Adds Asset Type to show on Pivot Table
.PivotFields("Asset Type").Orientation = xlRowField
With ActiveSheet.PivotTables("FlyingDays").PivotFields("Asset Type")
.PivotItems("B206").Visible = True
.PivotItems("B412").Visible = True
.PivotItems("C90B").Visible = True
.PivotItems("B206C").Visible = False
.PivotItems("B412C").Visible = False
.PivotItems("B412D").Visible = False
.PivotItems("B412S").Visible = False
.PivotItems("C90BI").Visible = False
.PivotItems("C90BS").Visible = False
.PivotItems("G120A").Visible = True
.PivotItems("GCPT4").Visible = False
.PivotItems("GCPT5").Visible = False
.PivotItems("G-DTT").Visible = False
.PivotItems("Room").Visible = False
.PivotItems("(blank)").Visible = False
End With
Thanks in advance for the help
I've written the following code for my pivot table. The Pivot Items. visible= "false" I do not want showing on my report. I only want the 4 items that equal True. Everything was working but this month, one of the Asset Types "B412D"
was not in my data so it crashed on line .PivotItems("B412D").Visible = False
Is there a better way to write this code to avoid it crashing when it does not find the Asset Type in the data being used? I have little VBA experience.
'Adds Asset Type to show on Pivot Table
.PivotFields("Asset Type").Orientation = xlRowField
With ActiveSheet.PivotTables("FlyingDays").PivotFields("Asset Type")
.PivotItems("B206").Visible = True
.PivotItems("B412").Visible = True
.PivotItems("C90B").Visible = True
.PivotItems("B206C").Visible = False
.PivotItems("B412C").Visible = False
.PivotItems("B412D").Visible = False
.PivotItems("B412S").Visible = False
.PivotItems("C90BI").Visible = False
.PivotItems("C90BS").Visible = False
.PivotItems("G120A").Visible = True
.PivotItems("GCPT4").Visible = False
.PivotItems("GCPT5").Visible = False
.PivotItems("G-DTT").Visible = False
.PivotItems("Room").Visible = False
.PivotItems("(blank)").Visible = False
End With
Thanks in advance for the help