[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 446
  • Last Modified:

Extract value of page field of an Excel pivot table

Hi,
For an Excel pivot table, by VBA, I would like to extract the selected values of a page field.
Example:
Page field name "city", with 3 potentials values: Montreal, Toronto, Vancouver
I would like to know what the user has selected.
If the user selects Montreal and Vancouver, I want to know its Montreal and Vancouver
If he selects Toronto, I want to know he has selected Toronto

Thanks
0
Karl001
Asked:
Karl001
1 Solution
 
Rgonzo1971Commented:
Hi,

pls try

Set pvtPageField = ActiveSheet.PivotTables("yourPivotTable1").PivotFields("city")
    For Each pvtItem In pvtPageField.PivotItems
        If pvtItem.Visible = True Then
            Res = Res & pvtItem.Name & ", "
        End If
    Next
Res = Left(Res, Len(Res) - 2)

Regards
0
 
Karl001Author Commented:
Thanks very much

Carol
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now