具有多个透视过滤器的Excel VBA

时间:2015-02-24 04:28:03

标签: excel vba excel-vba

我有一个数据透视表,我正在尝试使用Excel VBA在它们上创建多个过滤器。

条件:
我想要所有PCC 3级因此PivotFields("PCC Level")=3
我想要PivotFields("TowerLevel3")="Global Transition Services"

问题:
如果PCC级别为0,1,2,3,则应填充PivotFields("TowerLevel3")="Global Transition Services"

Sub Macro2()

    With ActiveSheet.PivotTables("PCC3ActionPlan").PivotFields("Project PCC Level")
        .PivotItems("0").Visible = False
        .PivotItems("1").Visible = False
        .PivotItems("2").Visible = False
        .PivotItems("3").Visible = True
    End With
    With ActiveSheet.PivotTables("PCC3ActionPlan").PivotFields("TowerLevel3")
        .PivotItems("Applications Consulting").Visible = False
        .PivotItems("Applications Development, Maintenance, & Support").Visible = _
        False
        .PivotItems("Applications Management and Support").Visible = False
        .PivotItems("Applications Modernization").Visible = False
        .PivotItems("Business Intelligence and Data Warehousing").Visible = False
        .PivotItems("Business Process Services").Visible = False
        .PivotItems("Cloud (non-Oracle)").Visible = False
        .PivotItems("Cloud (Oracle-based)").Visible = False
        .PivotItems("Consulting & Systems Integration").Visible = False
        .PivotItems("Enterprise Application Services").Visible = False
        .PivotItems("Enterprise Deployment Team").Visible = False
        .PivotItems("Enterprise Managed Security").Visible = False
        .PivotItems("Global Healthcare Consulting").Visible = False
        .PivotItems("Global Transition Services").Visible = True
        .PivotItems("Infrastructure & Technology Services").Visible = False
        .PivotItems("Infrastructure Consulting Services").Visible = False
        .PivotItems("Infrastructure Outsource Services").Visible = False
        .PivotItems("Insite One (acquisition)").Visible = False
    End With

End Sub

0 个答案:

没有答案