Pivot Table List Order

hatstand

Well-known Member
Joined
Mar 17, 2005
Messages
778
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I have tried and failed to work out how to modify this recorded line of code to allow me to use variables. The line is based on reordering a pivot table hierarchical field into the order that I want. I’m doing this as I can’t use Custom Lists as the list far exceeds the limit allowable.

What I’m after is to allow ‘Football’ and 'Position' to be variables, so when I loop the line I can say what position in the list the variables should be. Football position 1, Tennis position 2 etc.

Any pointers would be much appreciated.

ActiveSheet.PivotTables("PivotTest").PivotFields("[Respon_Table].[Responsibilities].[Sport]").PivotItems("[Respon_Table].[Responsibilities].[Sport].&[Football]").Position = 1
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi All, Isn't it always the case when you ask for help and work it out, sorry. This is how I did it, simple. Thanks

Dim i As Integer
Dim n As String

i = 1
n = "A"

'Column 0.................................................................................

ActiveSheet.PivotTables("PivotTest").PivotFields("[Respon_Table].[Responsibilities].[Sport]").PivotItems("[Respon_Table].[Responsibilities].[Sport].&[" & n & "]").Position = i
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,309
Members
449,080
Latest member
jmsotelo

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