Syntax

expression.AutoSort(Order, Field, PivotLine, CustomSubtotal)

expression A variable that represents a PivotField object.

Parameters

Name Required/Optional Data Type Description
Order Required Long One of the constants of specifying the sort order.
Field Required String The name of the sort key field. You must specify the unique name (as returned from the property), and not the displayed name.
PivotLine Optional Variant A line on a column or row in a PivotTable report.
CustomSubtotal Optional Variant The custom subtotal field.

Example

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

Visual Basic for Applications
ActiveSheet.PivotTables(1).PivotField("Company") _ .AutoSort xlDescending, "Sum of Sales"
auto sort Auto Sort Method AutoSort AutoSort Method Disable auto sorting? Establish automatic field sorting rules? Reset the sort order for automatic sorting? Set automatic sort parameters?

See also: