I have a specific range of values that I want hidden from view in a pivot table and cannot figure out how to simplify the following formula by using a range/variable for the .pivotitems?
I am trying to simplify the following code:
On Error Resume Next
With ActiveSheet.PivotTables("PivotTable1").PivotFields("LINE")
.PivotItems("510").Visible = False
.PivotItems("515").Visible = False
.PivotItems("520").Visible = False
.PivotItems("525").Visible = False
.PivotItems("530").Visible = False
.PivotItems("535").Visible = False
.PivotItems("540").Visible = False
.PivotItems("545").Visible = False
.PivotItems("550").Visible = False
.PivotItems("555").Visible = False
.PivotItems("560").Visible = False
.PivotItems("565").Visible = False
.PivotItems("570").Visible = False
.PivotItems("575").Visible = False
.PivotItems("580").Visible = False
.PivotItems("585").Visible = False
.PivotItems("590").Visible = False
.PivotItems("595").Visible = False
.PivotItems("520").Visible = False
.PivotItems("615").Visible = False
.PivotItems("640").Visible = False
.PivotItems("645").Visible = False
.PivotItems("650").Visible = False
.PivotItems("655").Visible = False
.PivotItems("660").Visible = False
.PivotItems("665").Visible = False
.PivotItems("670").Visible = False
.PivotItems("675").Visible = False
End With
Next
I am trying to simplify the following code:
On Error Resume Next
With ActiveSheet.PivotTables("PivotTable1").PivotFields("LINE")
.PivotItems("510").Visible = False
.PivotItems("515").Visible = False
.PivotItems("520").Visible = False
.PivotItems("525").Visible = False
.PivotItems("530").Visible = False
.PivotItems("535").Visible = False
.PivotItems("540").Visible = False
.PivotItems("545").Visible = False
.PivotItems("550").Visible = False
.PivotItems("555").Visible = False
.PivotItems("560").Visible = False
.PivotItems("565").Visible = False
.PivotItems("570").Visible = False
.PivotItems("575").Visible = False
.PivotItems("580").Visible = False
.PivotItems("585").Visible = False
.PivotItems("590").Visible = False
.PivotItems("595").Visible = False
.PivotItems("520").Visible = False
.PivotItems("615").Visible = False
.PivotItems("640").Visible = False
.PivotItems("645").Visible = False
.PivotItems("650").Visible = False
.PivotItems("655").Visible = False
.PivotItems("660").Visible = False
.PivotItems("665").Visible = False
.PivotItems("670").Visible = False
.PivotItems("675").Visible = False
End With
Next