在vba中要显示或隐藏数据透视表的行列总计,需要设置PivotTable对象的RowGrand和ColumnGrand属性。
其中RowGrand属性设置数据透视表的行总计,ColumnGrand属性设置数据透视表的列总计。
以下vba代码举例演示了如何显示或隐藏数据透视表的行列总计:
Sub QQ1722187970()
Dim oPC As PivotCache
Dim oPT As PivotTable
Dim oPF As PivotField
Dim oPI As PivotItem
Dim oWK As Worksheet
Set oWK = Sheet8
Set oPT = oWK.PivotTables(1)
With oPT
'对行总计禁用
.RowGrand = False
'启用列总计
.ColumnGrand = True
End With
End Sub


发表评论