-->
Establishes automatic field-sorting rules for PivotTable reports.
In Excel for Mac, you can sort a list of data by days of the week or months of the year. Or, create your own custom list for items that don't sort well alphabetically. You can also sort by font color, cell color, or icon sets. If you have Kutools for Excel installed, you can reverse the numbers order of columns with Flip Vertical Range tool quickly. Before applying Kutools for Excel, please.
expression.AutoSort (Order, Field, PivotLine, CustomSubtotal)
expression A variable that represents a PivotField object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
Order | Required | Long | One of the XlSortOrder constants specifying the sort order. |
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. |
PivotLine | Optional | Variant | A line on a column or row in a PivotTable report. |
CustomSubtotal | Optional | Variant | The custom subtotal field. |
This example sorts the Company field in descending order, based on the sum of sales.
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.