PivotField.Subtotals property (Excel)

Returns or sets subtotals displayed with the specified field. Valid only for nondata fields. Read/write Variant.

Syntax

expression.Subtotals (Index)

expression A variable that represents a PivotField object.

Parameters

Name Required/Optional Data type Description
Index Optional Variant A subtotal index, as shown in the following table. If this argument is omitted, the Subtotals method returns an array that contains a Boolean value for each subtotal.

Remarks

If an index is True, the field shows that subtotal. If index 1 (Automatic) is True, all other values are set to False.

Index Description
1 Automatic
2 Sum
3 Count
4 Average
5 Max
6 Min
7 Product
8 Count Nums
9 StdDev
10 StdDevp
11 Var
12 Varp

For OLAP data sources, Index can only return or be set to 1 (Automatic). The returned array always contains True or False for the first array element, and it contains False for all other elements. An array of element values that are all False indicates that there are no subtotals.

Example

This example sets the field that contains the active cell to show Sum subtotals.

Worksheets("Sheet1").Activate 
ActiveCell.PivotField.Subtotals(2) = True

Support and feedback

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.