Pivot Tables - Find number of selected values in Page, Row labels and Column labels filters

HikC

New Member
Joined
Jun 28, 2011
Messages
11
Hi,

In a pivot table I want to find the number of selected values (i.e. not the actual values themselves) in the Page, Row labels and Column labels filters, respectively.

I started out with the row and column filters and those elements of the code still work as expected. Unaware of the lurking disappointment I then copied the code to the page filter ...

No matter what selections I make in the page filter the code returns '0'. When I record the sequence where I set the page filter, the code contains bits like ".CurrentPage" and "=Array()", but I cannot get my head around it.

Could anyone give me a push in the right direction?

Thanks,
Henrik

Code:
'   Count the number of individual values selected in the "Page"-filter (Opportunity Classification)
CtOfValsPge = shtPivot1.PivotTables("PivotTable1").PivotFields("[Table1].[Opportunity Classification].[Opportunity Classification]").VisibleItems.Count '   Always returns '0' ?

'   Count the number of individual values selected in the "Row Labels"-filter (Process Stage Name)
CtOfValsRow = shtPivot1.PivotTables("PivotTable1").PivotFields("[Table1].[Process Stage Name (Process Stage) (Process Stage)].[Process Stage Name (Process Stage) (Process Stage)]") _
    .VisibleItems.Count
    
'   Count the number of individual values selected in the "Column Labels"-filter (Expected Sales Date (Year))
CtOfValsCol = shtPivot1.PivotTables("PivotTable1").PivotFields("[Table1].[Expected Sales Date (Year)].[Expected Sales Date (Year)]").VisibleItems.Count
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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