Applies To
PivotTable Object.
Description
Adds row, column and page fields to the PivotTable.
Syntax
object.AddFields(rowFields, columnFields, pageFields, addToTable)
object
Required. The PivotTable object.
rowFields
Optional. Specifies a pivot field name (or an array of pivot field names) to be added as rows.
columnFields
Optional. Specifies a pivot field name (or an array of pivot field names) to be added as columns.
pageFields
Optional. Specifies a pivot field name (or an array of pivot field names) to be added as pages.
addToTable
Optional. If True, the fields are added to the PivotTable (none of the existing fields are replaced). If False, the new fields replace existing fields. The default is False if this argument is not specified.
Remarks
You must specify one of the field arguments.
See Also
ColumnFields Method, DataFields Method, HiddenFields Method, PageFields Method, RowFields Method, VisibleFields Method.
Example
This example replaces the existing column fields in PivotTable one on Sheet1 with the Status and Closed_By fields.
Worksheets("Sheet1").PivotTables(1).AddFields _ ColumnFields:=Array("Status", "Closed_By")