如何使用VBA访问报表筛选器中存在的数据透视字段的数据透视项目 [英] How to access Pivot Items of a Pivot Field which is present in Report Filter using VBA

查看:143
本文介绍了如何使用VBA访问报表筛选器中存在的数据透视字段的数据透视项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码打印每个PivotField中存在的数据透视项及其可见状态.我在报告过滤器中有5个数据透视字段.

I used the below code to print the Pivot Items present in Each PivotField and their visible status. I have 5 Pivot Fields in the Report Filter.

问题是,它正在正确获取数据透视字段的数量.但是当涉及到数据透视表项的数量时,每个数据透视表字段都返回0.实际上,每个字段都有许多项目.我不是要打印可见的项目.但是物品及其可见状态.

The problem is, it is fetching the no.of Pivot Fields Properly. But when it comes to the no.of Pivot Items is returning 0 for every pivot field. In real each Field has many items. I'm not trying to print the visible items. But Items and their Visible Status.

Dim pf As PivotField
Dim pt As PivotTable
Dim pi As PivotItem

Set pt = Sheets("Reasons").PivotTables("PivotFields")
For Each pf In pt.PageFields
     For Each pi In pf.PivotItems
         Debug.Print pi.Name & " : " & pi.Visible
     Next
Next

推荐答案

在下面的链接中查看我的代码,该代码使您在无法使用切片器的情况下有效地同步数据透视表 http://blog.contextures.com/archives/2012/08/28/update-specific-pivot-tables-automatically/

See my code at the below link that lets you sync PivotTables efficiently in the event that you can't use Slicers http://blog.contextures.com/archives/2012/08/28/update-specific-pivot-tables-automatically/

这篇关于如何使用VBA访问报表筛选器中存在的数据透视字段的数据透视项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆