So here is what I've been using but when it does not have a blank or (blank) in the pivot table then I get a debug error. How can I get this to work but ti skip if its an error or if it does not exist instead of erroring out
Code:
' Filter out blanks on Pivot Tables
Sheets("Pivot").Activate
ActiveWorkbook.RefreshAll
Sheets("Pivot").PivotTables("PivotTable5").PivotFields("Legacy Item #"). _
ClearAllFilters
With Sheets("Pivot").PivotTables("PivotTable5").PivotFields("Legacy Item #")
.PivotItems("(blank)").Visible = False
End With
Sheets("Pivot").PivotTables("PivotTable1").PivotFields("SOS").ClearAllFilters
With Sheets("Pivot").PivotTables("PivotTable1").PivotFields("SOS")
.PivotItems("").Visible = False
.PivotItems("(blank)").Visible = False
End With