"透视字段分类汇总" 属性 (Excel)PivotField.Subtotals property (Excel)

返回或设置与指定字段同时显示的分类汇总。Returns or sets subtotals displayed with the specified field. 仅对非数据字段有效。Valid only for nondata fields. 读/写 VariantRead/write Variant.

语法Syntax

表达式分类汇总(索引)expression.Subtotals (Index)

_表达式_一个代表**透视字段** 对象的变量。expression A variable that represents a PivotField object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
IndexIndex 可选Optional VariantVariant 表示下表所显示的分类汇总索引。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

如果索引为 True,则该字段显示分类汇总。If an index is True, the field shows that subtotal. 如果索引 1(自动)为 True,则其他所有值将设置为 FalseIf index 1 (Automatic) is True, all other values are set to False.

IndexIndex 说明Description
11 自动Automatic
双面2 SumSum
第三章3 CountCount
44 平均Average
55 MaxMax
6 MinMin
7 产品Product
utf-88 数值计数Count Nums
9 StdDevStdDev
10 10 StdDevpStdDevp
11 11 VarVar
12 12 VarpVarp

对于 OLAP 数据源,Index 只能返回或设置为 1(自动)。For OLAP data sources, Index can only return or be set to 1 (Automatic). 返回的数组对第一个数组元素总是包含 TrueFalse,而对所有其他元素则包含 FalseThe returned array always contains True or False for the first array element, and it contains False for all other elements. 数组中所有元素的值都为 False,则表明没有分类汇总。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

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.