Using VBA to Loop through pivot iitems for a pivot field in a pivot table with a page field filter.

peejay

Board Regular
Joined
Jul 11, 2003
Messages
83
Hi
I've Googled my brains out trying to find an answer to this, so I'm giving up and posting a thread here to see if I can get an answer.

I am using VBA to (try) and traverse a pivot field in a pivot table, where I have a page field with a single filter value selected.
When I loop through the pivot items for the field, I get all of the different values present in the field itself, but I acutally just want the items returned to the pivot which exist for the page field value.

Here's what it looks like:

BUSINESS Tax <- Page filter value


LOCATION LOCATION #
Melbourne 13100
Sydney 12100
Adelaide 15195
Perth 16130

In the example, my Page Field contains my Business names (eg Tax, Audit, Consulting)
I have 10 different locations these businesses may be found at - but Tax is only done in the 4 locations shown in the LOCATION pivot field.

When I traverse the Location field, I get all 10 locations, but what I want is just the 4 (shown) resulting after applying the Tax filter.

Clear as mud?!?

Maybe its some combination of the Page Field & Pivot Field in the code, but I just catn't figure it out.
I've read an article by Jon Peltier which shows you how to select the DataRange of a pivot field, but I just want to pick up the field's values and not have to select the range. I'm presuming this is possible?

MANY thanks in advance.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,215,001
Messages
6,122,648
Members
449,092
Latest member
peppernaut

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