Using Excel 2016, I have a macro that works well if the data is in the pivot table, but if not, it throws an error (Run-Time error '1004': Unable to get the PivotItems proery of the PivotField class).
It is try to deselect the District Bank and Regional Trust but they may or may not not appear when macro runs.
Is there a way to prevent the macro from hanging up here?
Thanks,
ActiveSheet.PivotTables("PivotTable1").PivotFields("Branch").CurrentPage = _
"(All)"
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Branch")
.PivotItems("District Bank - Direct").Visible = False
.PivotItems("District Bank - Retail").Visible = False
.PivotItems("Regional Trust - North 1").Visible = False
.PivotItems("Regional Trust - South 1").Visible = False
.PivotItems("(blank)").Visible = False
End With
It is try to deselect the District Bank and Regional Trust but they may or may not not appear when macro runs.
Is there a way to prevent the macro from hanging up here?
Thanks,
ActiveSheet.PivotTables("PivotTable1").PivotFields("Branch").CurrentPage = _
"(All)"
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Branch")
.PivotItems("District Bank - Direct").Visible = False
.PivotItems("District Bank - Retail").Visible = False
.PivotItems("Regional Trust - North 1").Visible = False
.PivotItems("Regional Trust - South 1").Visible = False
.PivotItems("(blank)").Visible = False
End With