通过 Excel VBA 更改数据透视表的报告布局
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19509452/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing Report Layout of a pivot table By Excel VBA
提问by Amritha
I am generating a pivot table using VBA in Excel. By default the Report Layout is 'Outline Form'
. How can I change this to 'Compact form'
or 'Tabular Form'
through my code ? Any help is appreciated ! Thanks.
我正在 Excel 中使用 VBA 生成数据透视表。默认情况下,报告布局是'Outline Form'
. 如何将其更改为'Compact form'
或'Tabular Form'
通过我的代码?任何帮助表示赞赏!谢谢。
回答by Doug Glancy
By running the Macro Recorder I get this code for changing it to Compact:
通过运行宏记录器,我得到了将其更改为 Compact 的代码:
ActiveSheet.PivotTables("PivotTable1").RowAxisLayout xlCompactRow
To get it into Tabular Form, sure enough:
要把它变成表格形式,果然:
ActiveSheet.PivotTables("PivotTable1").RowAxisLayout xlTabularRow
Remember, the Macro Recorder is your friend.
请记住,宏记录器是您的朋友。