【问题标题】:Automatically change pivot table filter when another one changes当另一个更改时自动更改数据透视表过滤器
【发布时间】:2016-11-03 19:00:30
【问题描述】:

好的,我有两个数据透视表,我希望它们始终显示相同的过滤器。问题是,过滤器的标签不同。例如,第一个表中的过滤器“A”对应于第二个表中的过滤器“1”。 I have it working fine with a lookup if just one filter is selected, the problem is when multiple filters are selected I don't know how to handle it.任何想法将不胜感激。

另外,我知道最简单的方法是更改​​过滤器,使它们标记为相同,但我无权访问数据,所以这不是一个选项

【问题讨论】:

  • 嗨 - 你有哪个版本的 Excel?因为如果您在 2010 年,您可以使用“切片器”并将其连接到两个数据透视表

标签: excel filter pivot-table vba


【解决方案1】:

我正在使用Worksheet_PivotTableUpdate 事件。您将获得 Target 作为调用表。

 Dim chgPt as PivotTable
 Set chgPt = Target

 'You'll need to catch the change for either table.
 If chgPt.Name = "table1" Then 'Change table2
   pt2.PivotFields("nameOfFilter").CurrentPage = chgPt.PivotFields("nameOfFilter").CurrentPage 

 Else 'Change table1
  pt1.PivotFields("nameOfFilter").CurrentPage = chgPt.PivotFields("nameOfFilter").CurrentPage

 End If 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-06
    • 1970-01-01
    • 2017-07-30
    • 2012-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多