使用VBA进行数据透视表报告过滤

时间:2022-09-15 21:57:37

I am trying to automate a particular Pivot table filtering using VBA. I am not sure how to add "Report Filter" (please see attached screen shot) using VBA.

我试图使用VBA自动化特定的数据透视表过滤。我不知道如何使用VBA添加“报表过滤器”(请参阅​​随附的屏幕截图)。

To automate the process, I got the code for adding rows , columns and values , but can't seem to find the code for report filter.

为了自动化该过程,我获得了添加行,列和值的代码,但似乎无法找到报表过滤器的代码。

Can you please help me out with the code for this.

你可以帮我解决这个问题吗?

使用VBA进行数据透视表报告过滤

使用VBA进行数据透视表报告过滤

1 个解决方案

#1


0  

Thanks @avb for the suggestion . Recording the macro helped. The code for adding pivot report filter is this.

谢谢@avb的建议。录制宏有帮助。添加数据透视报告过滤器的代码就是这个。

    Sub pivotReportFilter(ptUse As PivotTable, fName As String)

     With ptUse.PivotFields(fName)
      .Orientation = xlPageField
      .Position = 1
     End With

   End Sub

#1


0  

Thanks @avb for the suggestion . Recording the macro helped. The code for adding pivot report filter is this.

谢谢@avb的建议。录制宏有帮助。添加数据透视报告过滤器的代码就是这个。

    Sub pivotReportFilter(ptUse As PivotTable, fName As String)

     With ptUse.PivotFields(fName)
      .Orientation = xlPageField
      .Position = 1
     End With

   End Sub