Class PivotField (Excel VBA)

The class PivotField represents a field in a PivotTable report.

The classes PivotCell, PivotFilter, PivotTable and Range. give access to class PivotField

Member in collection

Item

To use a PivotField class variable it first needs to be instantiated, for example

Dim pvtf as PivotField
Set pvtf = ActiveCell.PivotField

The following procedures can be used to set variables of type PivotField: CalculatedFields.Add, CalculatedFields.Item, PivotCell.DataField, PivotCell.PivotField, ChildField, ParentField, PropertyParentField, PivotFields.Item, PivotFilter.DataField, PivotFilter.MemberPropertyField, PivotFilter.PivotField, PivotItem.Parent, PivotItems.Parent, PivotTable.AddDataField, PivotTable.ColumnFields, PivotTable.DataFields, PivotTable.DataPivotField, PivotTable.HiddenFields, PivotTable.PageFields, PivotTable.RowFields, PivotTable.VisibleFields and Range.PivotField.

For Each

Here is an example of processing the PivotField items in a collection.

Dim pvtfCalculatedField As PivotField
For Each pvtfCalculatedField In Application.CalculatedFields()
	
Next pvtfCalculatedField

CalculatedFields.Add - Creates a new calculated field. Returns a PivotField object.

CalculatedFields.Item - Returns a single object from a collection.

AddPageItem - Adds an additional item to a multiple item page field.

AutoGroup - Automatically groups the pivot fields in a PivotTable.

AutoShow - Displays the number of top or bottom items for a row, page, or column field in the specified PivotTable report.

AutoSort - Establishes automatic field-sorting rules for PivotTable reports.

CalculatedItems - Returns a CalculatedItems collection that represents all the calculated items in the specified PivotTable report.

ClearAllFilters - Calling this method deletes all filters currently applied to the PivotField. This includes deleting all filters from the PivotFilters collection of the PivotField and removing any manual filtering applied to the PivotField as well. If the PivotField is in the Report Filter area, the item selected will be set to the default item.

ClearLabelFilters - This method deletes all label filters or all date filters in the PivotFilters collection of the PivotField.

ClearManualFilter - Provides an easy way to set the Visible property to True for all items of a PivotField in PivotTables, and to empty the HiddenItemsList and VisibleItemsList collections in OLAP PivotTables.

ClearValueFilters - Calling this method deletes all value filters in the PivotFilters collection of the PivotField.

Delete - Deletes the object.

DrillTo - The DrillTo method supports drilling to a specified PivotField from another PivotField.

PivotItems - Returns an pivotitems that represents either a single PivotTable item (a PivotItem pivotitems) or a collection of all the visible and hidden items (a PivotItems pivotitems) in the specified field. Read-only.

PivotFields.Item - Returns a single object from a collection.

Properties

Value (Default member) - Returns or sets a String value that represents the name of the specified field in the PivotTable report.

CalculatedFields.Count returns a Long value that represents the number of objects in the collection.

AllItemsVisible used to retrieve a Boolean value that indicates whether any manual filtering is applied to the PivotField.

AutoShowCount returns the number of top or bottom items that are automatically shown in the specified PivotTable field.

AutoShowField returns the name of the data field used to determine the top or bottom items that are automatically shown in the specified PivotTable field.

AutoShowRange returns the xlTop constant if the top items are shown automatically in the specified PivotTable field; returns xlBottom if the bottom items are shown.

AutoShowType returns the xlAutomatic constant if AutoShow is enabled for the specified PivotTable field; returns xlManual if AutoShow is disabled.

AutoSortCustomSubtotal returns the name of the custom subtotal used to sort the specified PivotTable field automatically.

AutoSortField returns the name of the data field used to sort the specified PivotTable field automatically.

AutoSortOrder returns the order used to sort the specified PivotTable field automatically. Can be one of the XlSortOrder constants.

AutoSortPivotLine returns the name of the PivotLine object used to sort the specified PivotTable field automatically.

BaseField returns or sets the base field for a custom calculation. This property is valid only for data fields.

BaseItem returns or sets the item in the base field for a custom calculation. Valid only for data fields.

Calculation returns or sets an XlPivotFieldCalculation value that represents the type of calculation performed by the specified field. This property is valid only for data fields.

Caption returns a String value that represents the label text for the pivot field.

ChildField returns a PivotField object that represents the child field for the specified field (if the field is grouped and has a child field).

ChildItems returns an pivotitem that represents either a single PivotTable item (a PivotItem pivotitem) or a collection of all the items (a PivotItems pivotitem) that are group children in the specified field, or children of the specified item. Read-only.

CubeField returns the CubeField object from which the specified PivotTable field is descended.

CurrentPage returns or sets the current page showing for the page field (valid only for page fields). Read/write PivotItem.

CurrentPageList returns or sets an array of strings corresponding to the list of items included in a multiple-item page field of a PivotTable report.

CurrentPageName returns or sets the currently displayed page of the specified PivotTable report. The name of the page appears in the page field. Note that this property works only if the currently displayed page already exists.

DatabaseSort when set to True, manual repositioning of items in a PivotTable field is allowed. Returns True if the field has no manually positioned items.

DataRange returns a Range object as shown in the following table.

DataType returns an XlPivotFieldDataType value that represents the type of data in the PivotTable field.

DisplayAsCaption this property is used to display member properties of PivotFields as captions.

DisplayAsTooltip this property is used to specify whether a specific member property PivotField is displayed in tooltips.

DisplayInReport this property is used to specify whether the specified member property PivotField is displayed in the PivotTable or not.

DragToColumn true if the specified field can be dragged to the column position. The default value is True.

DragToData true if the specified field can be dragged to the data position. The default value is True.

DragToHide true if the field can be hidden by being dragged off the PivotTable report. The default value is True.

DragToPage true if the field can be dragged to the page position. The default value is True.

DragToRow true if the field can be dragged to the row position. The default value is True.

DrilledDown true if the flag for the specified PivotTable field or PivotTable item is set to "drilled" (expanded, or visible).

EnableItemSelection when set to False, disables the ability to use the field dropdown in the user interface. The default value is True.

EnableMultiplePageItems used for specifying whether check boxes are present in the filter drop-down list for fields in the page area.

Formula returns or sets a String value that represents the object's formula in A1-style notation and in the language of the macro.

Function returns or sets the function used to summarize the PivotTable field (data fields only).

GroupLevel returns the placement of the specified field within a group of fields (if the field is a member of a grouped set of fields).

Hidden this property is used to hide the individual levels of an OLAP hierarchy.

HiddenItems returns an pivotitem that represents either a single hidden PivotTable item (a PivotItem pivotitem) or a collection of all the hidden items (a PivotItems pivotitem) in the specified field. Read-only.

HiddenItemsList returns or sets a Variant specifying an array of strings that are hidden items for a PivotTable field.

IncludeNewItemsInFilter allows developers to specify whether excluded or included items should be tracked when manual filtering is applied to the PivotField.

IsCalculated true if the PivotTable field is a calculated field or item.

IsMemberProperty returns True when the PivotField contains member properties.

LabelRange returns a Range object that represents the cell (or cells) that contain the field label.

LayoutBlankLine true if a blank row is inserted after the specified row field in a PivotTable report. The default value is False.

LayoutCompactRow specifies whether or not a PivotField is compacted (items of multiple PivotFields are displayed in a single column) when rows are selected.

LayoutForm returns or sets the way the specified PivotTable items appear—in table format or in outline format.

LayoutPageBreak true if a page break is inserted after each field. The default value is False.

LayoutSubtotalLocation returns or sets the position of the PivotTable field subtotals in relation to (either above or below) the specified field.

MemberPropertyCaption setting the MemberPropertyCaption property controls which member property is used as a caption for a given level.

MemoryUsed returns the amount of memory currently being used by the object, in bytes.

Name returns or sets a String value representing the name of the object.

NumberFormat returns or sets a String value that represents the format code for the object.

Orientation returns or sets an XlPivotFieldOrientation value that represents the location of the field in the specified PivotTable report.

ParentField returns a PivotField object that represents the PivotTable field that's the group parent of the specified object. The field must be grouped and must have a parent field.

ParentItems returns an pivotitem that represents either a single PivotTable item (a PivotItem pivotitem) or a collection of all the items (a PivotItems pivotitem) that are group parents in the specified field. The specified field must be a group parent of another field. Read-only.

PivotFilters returns or sets the PivotFilters for the specified PivotField object.

Position returns or sets a value that represents the position of the field (first, second, third, and so on) among all the fields in its orientation (Rows, Columns, Pages, Data).

PropertyOrder valid only for PivotTable fields that are member property fields. Returns a Long indicating the display position of the member property within the cube field to which it belongs.

PropertyParentField returns a PivotField object representing the field to which the properties in this field pertain.

RepeatLabels returns or sets whether item labels are repeated in the PivotTable for the specified PivotField.

ServerBased true if the data source for the specified PivotTable report is external and only the items matching the page field selection are retrieved.

ShowAllItems true if all items in the PivotTable report are displayed, even if they don't contain summary data. The default value is False.

ShowDetail gets or sets whether the specified PivotField object is showing detail.

ShowingInAxis indicates if the PivotField is currently visible in the PivotTable or not.

SourceCaption the SourceCaption property is applicable only for OLAP PivotTables, and returns the original caption from the OLAP server for a PivotField.

SourceName returns a String value that represents the specified object's name as it appears in the original source data for the specified PivotTable report.

StandardFormula returns or sets a String specifying formulas with standard English (United States) formatting.

SubtotalName returns or sets the text string label displayed in the subtotal column or row heading in the specified PivotTable report. The default value is the string Subtotal.

Subtotals returns or sets subtotals displayed with the specified field. Valid only for nondata fields.

TotalLevels returns the total number of fields in the current field group. If the field isn't grouped, or if the data source is OLAP-based, TotalLevels returns the value 1. Read-only Long.

UseMemberPropertyAsCaption this property is used to control whether member property captions are used for PivotItem captions of the PivotField.

VisibleItems returns an pivotitem that represents either a single visible PivotTable item (a PivotItem pivotitem) or a collection of all the visible items (a PivotItems pivotitem) in the specified field. Read-only.

VisibleItemsList returns or sets a Variant specifying an array of strings that represent included items in a manual filter applied to a PivotField.

PivotFields.Count returns a Long value that represents the number of objects in the collection.

CalculatedItems - A collection of PivotItem objects that represents all the calculated items in the specified PivotTable report.

CubeField - Represents a hierarchy or measure field from an OLAP cube. In a PivotTable report, the CubeField object is a member of the CubeFields collection.

PivotFilters - The PivotFilters object is a collection of PivotFilter objects.

PivotItem - Represents an item in a PivotTable field.

PivotItems - A collection of all the PivotItem objects in a PivotTable field.

PivotLine - A PivotLine object is a line of rows or columns in an Excel PivotTable.

Range - Represents a cell, a row, a column, a selection of cells containing one or more contiguous blocks of cells, or a 3D range.