简体   繁体   English

使用VBA识别数据透视字段

[英]Identify Pivot Field using VBA

I am trying to write a macro which automatically identifies which field is the data taken from in a pivot. 我正在尝试编写一个宏,该宏可以自动识别哪个字段是数据透视图中的数据。

I have some columns with different level of org information dragged under one another in "Row Labels" to create a structure. 我在“行标签”(Row Labels)中将一些具有不同级别的组织信息的列相互拖动以创建结构。 Now I need to identify which row in the pivot is linked to which field. 现在,我需要确定枢轴中的哪一行链接到哪个字段。

I am a self-taught coder and am very new to advanced vba so need some help. 我是一名自学成才的编码员,对高级vba还是很陌生,因此需要一些帮助。

How my pivots look 我的支点看起来如何

我的支点看起来如何

I am trying to get the name of the field in the blue circle 我正在尝试在蓝色圆圈中获取字段的名称

我正在尝试在蓝色圆圈中获取字段的名称

Thank you! 谢谢!

Nevermind guys, It was simpler than I thought. 没关系的家伙,这比我想的要简单。 I am just an idiot for not figuring it out earlier. 我只是个白痴,没有早点弄清楚。

Anyhow, the solution is that "ActiveCell.PivotField" returns the Pivot row's field. 无论如何,解决方案是“ ActiveCell.PivotField”返回“数据透视表”行的字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM