April 2006
Beginner
1114 pages
98h 16m
English
pivotfield.AutoSort(Order, Field)
Sort items in a pivot field
|
Argument |
Settings |
|---|---|
|
|
Can be |
|
|
The data field to sort |
These settings are equivalent to the AutoSort Options on the PivotTable Field Advanced Options dialog box shown in Figure 13-20.
The following code sorts items in the ProductName field by sales rank:
Sub SortBySalesRank( )
Dim pt As PivotTable, pf As PivotField
' Uncomment this line to create pivot table.
'CreatePivotTable
' Get pivot table.
Set pt = Worksheets("BookSales").PivotTables(1)
' Get pivot field.
Set pf = pt.PivotFields("ProductName")
' Sort items
pf.AutoSort xlAscending, pt.DataFields(1).name
End SubRead now
Unlock full access