VBA, PivotTable: Move the first PivotField, regardless of name, to the last position

wookieking

New Member
Joined
Nov 7, 2017
Messages
1
I have a workbook with about 30 tabs that each have 6 PivotCharts. Each PivotChart has 12 PivotFields (Values) corresponding to the months of the year. These are basically creating a rolling year effect after data is updated. To do this effect, I need to take the PivotField in .Position = 1 and change it to .Position = 12 each time the macro is run.

I obviously can't use .PivotTables("xyz").PivotFields("Nov") because the top won't always be "Nov". I don't want to make the field name dependent upon when the macro is run because it might not be run in the correct month causing the months to be out of order and/or not being reflective of when the report actually should have been run.

Everything I've found doesn't tell me how to grab the name value of field 1. Lots of stuff telling me how to get the position value of a hard coded name, though.

Any help is appreciated.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

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