AutoSort Method [Excel 2003 VBA Language Reference]

Establishes automatic field-sorting rules for PivotTable reports.

expression**.AutoSort(Order**, Field)

expression Required. An expression that returns one of the objects in the Applies To list.


XlSortOrder can be one of these XlSortOrder constants.
xlManual. To disable automatic sorting.

Field   Required String. The name of the sort key field. You must specify the unique name (as returned from the SourceName property), and not the displayed name.


This example sorts the Company field in descending order, based on the sum of sales.

ActiveSheet.PivotTables(1).PivotField("Company") _
    .AutoSort xlDescending, "Sum of Sales"

Applies to | PivotField Object