英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论