mardi 31 mars 2015

PivotTable how to set all items in filter to false?

I have a MS Excel macro that creates a PivotTable. Within the PivotTable I want to filter on multiple items. So first you need to set all items to false and then set the items you want to include to true. So currently I have:



With ActiveSheet.PivotTables("PivotTable2").PivotFields("Test Cycle")
.PivotItems("FXA BI_MH Pre UAT C1").Visible = False
.PivotItems("FXA BI_MH Pre UAT C2").Visible = False
.PivotItems("FXA Reg C1").Visible = False
.PivotItems("MC3").Visible = False
.PivotItems("PT Cycle 1").Visible = False
.PivotItems("Regression Test (APO)").Visible = False
.PivotItems("SIT CR").Visible = False
.PivotItems("SIT Cycle 2").Visible = False
.PivotItems("UAT - Data Conv").Visible = False
.PivotItems("UAT Pre-Test - Additional").Visible = False
.PivotItems("UAT Pre-Test - Final").Visible = False
.PivotItems("UAT Pre-Test - Iteration 2").Visible = False
End With
ActiveSheet.PivotTables("PivotTable2").PivotFields("Test Cycle"). _
EnableMultiplePageItems = True


However, the "Test Cycle" items change and if a new one is introduced it is automatically included as I have not set it to false. Is there a way to just set all selections to false, something like (which does not work):



With ActiveSheet.PivotTables("PivotTable2").PivotFields("Test Cycle")
.PivotItems("(All)").Visible = False
End With
ActiveSheet.PivotTables("PivotTable2").PivotFields("Test Cycle"). _
EnableMultiplePageItems = True

Aucun commentaire:

Enregistrer un commentaire