Subtotals Property
Returns or sets subtotals displayed with the specified field. Valid only for nondata fields. Read/write Variant.
expression.Subtotals(Index)
expression Required. An expression that returns a PivotField object.
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.
Index | Meaning |
---|---|
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 |
If an index is True, the field shows that subtotal. If index 1 (Automatic) is True, all other values are set to False.
Remarks
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