Hello, I have data sets that need filtering in pivot tables in a macro. Sometimes the data has blanks and unwanted fields. How do I tell the macro to skip/bypass the filter command for unwanted said fields when the fields aren't present in the data and to continue running macro as normal.
Example: The macro pivot table needs to filter out AF35 and blank fields and if unwanted fields aren't present to continue running the rest of the macro.
VBA
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Financial Code")
.PivotItems("AF35").Visible = False
.PivotItems("(blank)").Visible = False
End With
Example: The macro pivot table needs to filter out AF35 and blank fields and if unwanted fields aren't present to continue running the rest of the macro.
VBA
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Financial Code")
.PivotItems("AF35").Visible = False
.PivotItems("(blank)").Visible = False
End With