PivotTable Do not show subtotals

江枫思渺然 提交于 2019-12-04 15:57:26

All, thanks to some more research I found the solution

Sub PivotTableLayout2b()
Dim PvtTbl As PivotTable
Dim pvtFld As PivotField

Set PvtTbl = ActiveSheet.PivotTables(1)

'hide Subtotals for all fields in the PivotTable .

With PvtTbl
 For Each pvtFld In .PivotFields
 pvtFld.Subtotals(1) = True
 pvtFld.Subtotals(1) = False
Next pvtFld
End With
End Sub

I found I did not need to set the subtotal to 'true' first. Setting it directly to false was fine.

.Subtotals = Array(False, False, False, False, False, False, False, False, False, False, False, False)

surely sets all possible subtotals to false, in one go.

Bojan Goldy
.PivotFields("Pivot Field Name").Subtotals = Array(False, False, False, False, False, False, False, False, False, False, False, False)

it is not better is it just to make it clear

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!