Article ID: 235537 - View products that this article applies to.
This article was previously published under Q235537
This step-by-step article describes how to custom sort a PivotTable or keep a PivotTable from being automatically sorted.
In Microsoft Excel, data in a PivotTable is automatically sorted. There are no options available to turn this automatic sorting off or to perform a custom sort on your PivotTable data.
To prevent a PivotTable from being sorted, you can create a custom list using the unsorted source data on the worksheet. To custom sort a PivotTable, you can first sort the source data as the way you want it on the worksheet, and then create a custom list using the sorted source data.
A PivotTable first uses a custom list to sort if possible. If an appropriate custom list is not available, then the PivotTable uses default sorting.
If there is a custom list that exactly matches the source data, then the PivotTable is sorted using the custom list. This may make the PivotTable appear to be unsorted.
Note that a custom list is only used when the PivotTable is created. If you use a new custom list for sorting, you must re-create the pivot table (you cannot just refresh the PivotTable).
The following examples demonstrate how to use a custom list to prevent a PivotTable from sorting and how to custom sort the data in your PivotTable.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners - https://partner.microsoft.com/global/30000104
Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
NOTES: If you add items to the source data after you create the PivotTable, and you refresh the PivotTable, the new items are only sorted correctly if they are included in the original custom list. Items that are not included in the original custom list are sorted after the items that are included in the original custom list.
After you create a PivotTable using a custom list, the PivotTable no longer uses the custom list for refreshing the data. Because of this behavior, if you change the custom list that you used to create the PivotTable, you must delete the PivotTable, and create a new PivotTable. Additionally, you can delete the original custom list and the PivotTable will still sort according to the original custom list.
Article ID: 235537 - Last Review: August 23, 2007 - Revision: 3.4