I’m trying to use VBA to extract and manipulate data from a pivot table.
My pivot table has three Row labels (D_Campaign, D_TL, D_Agent_Name).
Using
For Each pt1 In pt.RowFields("D_Agent_Name").PivotItems
Debug.Print pt1.Name
Next pt1
I can get a list of all the labels in ‘D_Agent_Name’. However, what I would like, is a list of the labels in ‘D_Agent_Name’ for a given value of ‘D_TL’. Can anyone point me in the right direction?
I think @gimp may be right that it’s easier to deal with the source data, but here’s something that works for me:
Call it like this:
I like programming pivot tables, and my experience is that there’s usually more than one way to skin a pivot table cat :). A very helpful reference for programming to pivot table ranges can be found on Jon Peltier’s site.