VBA折叠整个数据透视表,除了最后一个条目。

huangapple go评论73阅读模式
英文:

VBA to collapse entire pivot table except last entry

问题

我有一个宏用来刷新数据透视表 - 但是,在刷新后,所有包含“latest”数据的字段都会按照其固有设计展开。我想要折叠除最后一个和最新的条目之外的所有行。

希望能得到任何帮助,将不胜感激!

英文:

I have macro to refresh the pivot data - however, upon refresh all the fields with the 'latest' data become expanded as by inherent design. I'd like to collapse all the rows with the exception of the last, and latest, entry.

Any assistance would be appreciated!!!

答案1

得分: 0

在这里找到了...

    Dim pT As PivotTable
    Dim pF As PivotField

    Set pT = ActiveWorkbook.Worksheets("工作表名称").PivotTables(1)
    With pT
        For Each pF In pT.RowFields
            pF.DrillTo pF.Name
        Next pF
    End With
英文:

Found it here...

Dim pT As PivotTable
Dim pF As PivotField

Set pT = ActiveWorkbook.Worksheets("WorksheetName").PivotTables(1)
With pT
    For Each pF In pT.RowFields
        pF.DrillTo pF.Name
    Next pF
End With

huangapple
  • 本文由 发表于 2023年2月16日 03:11:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75464455.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定