My organization has ~100 divisions. These are rows in my Pivot table. I use VBA to create a new pivot table on a fresh data dump each week. My issue is a few times a year a division deleted or a new one is added in. My current pivot table uses only 15 divisions but my code is effected by all ~100 divisions. (my code below only shows a portion to save space)
I have tried searching the web for hours and using the macro recorder of a better solution than I am currently using.
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Flex Division - Text")
.PivotItems("03").Visible = False
.PivotItems("04").Visible = False
.PivotItems("05").Visible = False
.PivotItems("07").Visible = False
.PivotItems("1A").Visible = False
.PivotItems("1B").Visible = False
.PivotItems("1C").Visible = False
.PivotItems("1F").Visible = False
.PivotItems("1G").Visible = False
.PivotItems("1J").Visible = False
.PivotItems("1K").Visible = False
.PivotItems("(blank)").Visible = False
End With
The code above filters out divisions not in use. I want to do the opposite. I would like to un filter all divisions and then add back in the divisions I use. This will avoid future code adjustments.