loop each item in PT filter

MarkCBB

Active Member
Joined
Apr 12, 2010
Messages
497
HI there VBA pros,

I need some help completing this code, I have most of it done but I am getting stuck with an error.

I am trying to execute some code for each PI in the filter list, however I am getting stuck. below is the code that i have so far.

Code:
Sub mytest()

    With Sheets("CALCULATIONS").PivotTables("PivotTable1").PivotFields("CUSTOMER")
    For Each Pi In .PivotItems
    Pi.Visible = True
           If PivotItems <> Pi.Value = Pi.Visible = False Then
            'run this code
        End If
    Next Pi
         
    End With

End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Do you mean you want to filter a field by a particular value? CAn you explain in words what you want to do?
 
Upvote 0
HI there Jon,
I want to filter by each item in the filter list and then run some code then move onto the next item in the list
i.e. if the are 5 items in the pivot list, the first 1 is selected and the rest are deselected, then some code runs, then the next one is selected and the rest are deslected including the first 1 etc.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,735
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top