VBA 2010 How tell which pivotfield changed?

OccasionalGeek

New Member
Joined
Mar 1, 2012
Messages
12
Win 7, Excel 2010, VBA.

Using a "Sub Worksheet_PivotTableUpdate" 'trigger', I want to determine WHICH filter changed if a user made a new selection from a drop down list on the filter pivot field. (not the value that was chosen, but the field that was changed.)

The macro initiates whenever the user makes a new selection, no problem. But how do I identify the name (or index number) of the pivot field that changed? (there are 13 members of the PivotFields object). I can identify the pivot table (.name), and could get value it was changed to easily if I knew which pivot field changed. There are several pivot tables on the sheet.

All of the following code works fine - but I don't know how to tell which pivot field changed? (btw: The vctr.name and vctr.value both return identical data every time.) The code is on the sheet containing the pivot tables, of course.
Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim vCtr As Variant
'    MsgBox "Update"
    With Target
        MsgBox "Target Name ' " & .Name
        MsgBox "Pivotfields count = " & .PivotFields.Count
        For Each vCtr In .PivotFields
            MsgBox "Pivotfields name = " & vCtr.Name
            MsgBox "Pivotfields value = " & vCtr.Value
        Next vCtr
    End With
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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