I recorded a macro by going to a PivotTable, and in the dropdown for the field i was interested in, i checked "Select all)" and then pressed OK.
What VBA recorded was this:
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Vaca")
.PivotItems("excl").Visible = True
.PivotItems("Bost19").Visible = True
End With
Essentially, VBA "intelligently" figured out the only two items that were not Visible, and set those two items to Visible.
But, this code will not work in the "General" case, where you want all items to be visible, regardless of how many were visible before the code is executed. Is there a General way in VBA to ensure that all items are Visible (which is what the UI offers)? Or, do you have to loop through every item in a PivotField and individually set it to Visible=True?
Thanks!
What VBA recorded was this:
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Vaca")
.PivotItems("excl").Visible = True
.PivotItems("Bost19").Visible = True
End With
Essentially, VBA "intelligently" figured out the only two items that were not Visible, and set those two items to Visible.
But, this code will not work in the "General" case, where you want all items to be visible, regardless of how many were visible before the code is executed. Is there a General way in VBA to ensure that all items are Visible (which is what the UI offers)? Or, do you have to loop through every item in a PivotField and individually set it to Visible=True?
Thanks!