Move DataField in Pivot Table with VBA

dgrimm

Board Regular
Joined
Sep 17, 2007
Messages
157
I am trying to move a DataField to the beginning of the data fields. However when I try recording a macro it has a completely different field in the coding and says that it is adding the data field. So what I am trying to do is move "AGE" to be the first data field in the datafield list. I have tried clicking on it in the field list box and selecting move to beginning but that is giving the above code. Anyone have any ideas.

Thank you

Dave
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

par60056

Well-known Member
Joined
Jul 26, 2012
Messages
1,581
Office Version
  1. 2011
  2. 2010
Platform
  1. Windows
  2. MacOS
without any of your code, I can give you hints but you will need to fit it in the code.

I think what you want is the .Position property of the pivotField. I know this works for ordering the row and column fields. I have never needed to do it with the value fields.

Code:
        With .PivotFields("AGE")
            .Orientation = xlDataField
            .Position = 1
            .Calculation = xlNoAdditionalCalculation
        End With
 

par60056

Well-known Member
Joined
Jul 26, 2012
Messages
1,581
Office Version
  1. 2011
  2. 2010
Platform
  1. Windows
  2. MacOS
You are welcome. Thanks for letting me know it helped.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,277
Messages
5,836,350
Members
430,421
Latest member
Natas

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
Top