PivotField.AutoSort (Excel)

Establishes automatic field-sorting rules for PivotTable reports.

AutoSort (Order, Field, PivotLine, CustomSubtotal)


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

Arguments

The following arguments are required:

Order (Long) - One of the XlSortOrder constants specifying the sort order.

Field (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.

Optional arguments

The following arguments are optional

PivotLine (PivotLine) - A line on a column or row in a PivotTable report.

CustomSubtotal - The custom subtotal field