Trying to understand PIVOT TABLE pivot fields order, and change?

logandiana

Board Regular
Joined
Feb 21, 2017
Messages
107
What determines the order of the columns headings from left to right? In this example it appears to be alphabetical, but is that always the case? Is there any set rule to this? Could have sworn I'd seen an example where this wasn't the case before.
Is there a way to change the order using VBA?


Sum of Number
Color
Date
blue
green
orange
red
yellow
Grand Total
10/2/2017
11
11
10/3/2017
17
17
10/4/2017
14
14
10/5/2017
16
16
10/6/2017
11
11
10/7/2017
10
10
10/8/2017
14
14
10/9/2017
14
14
10/10/2017
17
17
10/11/2017
13
13
10/12/2017
16
16
10/13/2017
19
19
10/14/2017
13
13
10/15/2017
15
15
10/16/2017
17
17
10/17/2017
17
17
10/18/2017
13
13
10/19/2017
10
10
10/20/2017
11
11
10/21/2017
10
10
10/22/2017
12
12
Grand Total
64
61
28
65
72
290

<tbody>
</tbody>
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
By default it will be alphabetical but you can sort it pretty much any way you want, including an entirely manual order, either in VBA or in Excel itself. How are you trying to sort it?
 
Upvote 0
This was just an example, but lets say I'd like to use VBA to sort it in a specific order bases on names. For instance lets say I always want the order Red, Orange, Yellow, Green, Blue.
 
Upvote 0
You don't actually need VBA for that. If you create a custom list in that order, you can sort the field using that list.
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,555
Members
449,170
Latest member
Gkiller

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