Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 1.35 KB

Excel.PivotField.AutoSort.md

File metadata and controls

47 lines (30 loc) · 1.35 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
PivotField.AutoSort method (Excel)
vbaxl10.chm240157
vbaxl10.chm240157
Excel.PivotField.AutoSort
7a0bba4d-b18c-04df-a3b4-6ae2807f5238
05/04/2019
medium

PivotField.AutoSort method (Excel)

Establishes automatic field-sorting rules for PivotTable reports.

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

Example

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"

[!includeSupport and feedback]