Identify Used Fields in a Pivot Table using VBA

S Oberlander

Board Regular
Joined
Nov 25, 2020
Messages
147
Office Version
  1. 365
Platform
  1. Windows
Is there any way to identify the names of the active pivot table fields or to check if a specific field is active?

I have two fields, one is "Fee rates" the other is "Fee rates with Description",
I need to be able to identify which one is in use for the macro to be able to execute properly.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
you can activate and the hide the fields using something like the below

VBA Code:
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("BreachYN")
    For x = 1 To .PivotItems.Count
    'Debug.Print .PivotItems(x).Name, .PivotItems(x).Value
     .PivotItems(x).Visible = True
    Next
    
        .PivotItems("(blank)").Visible = False
        .PivotItems("0").Visible = False
    End With
 
Upvote 0
that is just hiding and unhiding pivot fields
I don't want to touch that, I only have to know which fields are active to direct other parts of the macro
 
Upvote 0

Forum statistics

Threads
1,215,172
Messages
6,123,443
Members
449,100
Latest member
sktz

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