小编Aid*_*son的帖子

VBA 数据透视表 折叠所有字段

我在 VBA 中创建了一个充满字符串数据的数据透视表,但似乎无法折叠数据透视表中的所有字段,我该怎么做?这是我的源代码

    SrcData = ActiveSheet.Name & "!" & Range(Cells(1, 1), Cells(46, 3)).Address(ReferenceStyle:=xlR1C1)
StartPvt = Sheets("Key Controls").Cells(2, 5).Address(ReferenceStyle:=xlR1C1)
Set pvtCache = ActiveWorkbook.PivotCaches.Create( _
    SourceType:=xlDatabase, _
    SourceData:=SrcData)
Set pvt = pvtCache.CreatePivotTable( _
    TableDestination:=StartPvt, _
    TableName:="PivotTable1")
pvt.PivotFields("SOP Reference").Orientation = xlRowField
pvt.PivotFields("Key Control ID").Orientation = xlRowField
pvt.PivotFields("Key Control Name").Orientation = xlRowField
Run Code Online (Sandbox Code Playgroud)

excel vba pivot-table

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

excel ×1

pivot-table ×1

vba ×1