VBA to add PivotItems if it is a child of another PivotField/item

Karter705

New Member
Joined
May 2, 2011
Messages
4
Hey everyone, thanks in advance for your help on this.

I am not sure that I phrased this correctly in the title, which may be why I haven't been able to find an answer anywhere else. I am not sure if it is even possible.

Essentially, I have two lists -- one is Division, the other is Region; I am reading in the pivot items into two list boxes. When you select a division in the first list box, I want to add the pivot items for Region that belong to the selected Division into the second list box. Is this possible?

Something like:
Code:
Sheet3.RegionList.Clear

Set pt = Sheet7.PivotTables("ChartPivot")
Set pf = pt.PivotFields("Region")

For Each pi In pf.PivotItems
    If pi something should go here to check if it is in the selected division
            Sheet3.RegionList.AddItem (pi)
    End If
Next pi

Thanks again!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I am interested in this as well, i believe it is something close to .parentitems()
Have you found a solution / alternative to this problem?

Thank you

BR
--
GMan
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,546
Members
449,169
Latest member
mm424

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