I have a very large pivot table including a pivot filter with many values (100+). I need to filter out to only a few of those values.
The documentation i've found and with macro record it shows this as the approach:
This will work, and to do it programatically i can loop through pivotitems instead of hard coding it... But it is very inefficient even if i turn off application redraw and application calculation.
Is there any better way to set the pivot filter values instead of a loop like this?
Thanks,
- Ben
The documentation i've found and with macro record it shows this as the approach:
VBA Code:
ActiveSheet.PivotTables("ptFull").PivotFields("PDM").CurrentPage = "(All)"
With ActiveSheet.PivotTables("ptFull").PivotFields("PDM")
.PivotItems("<PERSON1>").Visible = False
.PivotItems("<PERSON2>").Visible = False
.PivotItems("<PERSON3>").Visible = False
.PivotItems("<PERSON4>").Visible = False
.PivotItems("<PERSON5>").Visible = False
.PivotItems("<PERSON6>").Visible = False
.PivotItems("<PERSON7>").Visible = False
.PivotItems("<PERSON8>").Visible = False
.PivotItems("<PERSON9>").Visible = False
.PivotItems("<PERSON10>").Visible = False
.PivotItems("<PERSON11>").Visible = False
.PivotItems("<PERSON12>").Visible = False
.PivotItems("<PERSON13>").Visible = False
.PivotItems("<PERSON14>").Visible = False
.PivotItems("<PERSON15>").Visible = False
.PivotItems("<PERSON16>").Visible = False
.PivotItems("<PERSON17>").Visible = False
.PivotItems("<PERSON18>").Visible = False
.PivotItems("<PERSON19>").Visible = False
.PivotItems("<PERSON20>").Visible = False
End With
With ActiveSheet.PivotTables("ptFull").PivotFields("PDM")
.PivotItems("<PERSON21>").Visible = False
[B]'AND ON AND ON AND ON for everyone NOT wanted[/B]
End With
ActiveSheet.PivotTables("ptFull").PivotFields("PDM").EnableMultiplePageItems =True
This will work, and to do it programatically i can loop through pivotitems instead of hard coding it... But it is very inefficient even if i turn off application redraw and application calculation.
Is there any better way to set the pivot filter values instead of a loop like this?
Thanks,
- Ben