最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

excel - VBA Code to filter data in "SalesData" Sheet based on when users double click in a PivotTable range in

programmeradmin4浏览0评论

I am trying to filter data when the user double clicks a cell of a pivot table range in sheet "Pivot" then that field should gets filtered from "SalesData" Sheet. I know how to filter data only from one column.

But here the problem is that we don't know what user wants. He/she can double click on Region/Manager/SalesMan/Item etc. Based on their double click in "Pivot" sheet the same data should be filtered from "SalesData" Sheet.

Example: When the user double clicks on "Timothy", then this filed should be filtered from "Manager" (Column C) or when the user double clicks on "Television" then this field should be filtered from "Item" (Column E) etc. I am using the hierarchy in the pivot table and users can double click on any item from Column A of the entire pivot table range.

I know how to filter using simple VBA as shown below, however it would be great if solution is possible for the problem mentioned above.

Sub FilterRows()
     With Worksheets("SalesData").Range("A1")
          .AutoFilter field:=2, Criteria1:="East"
          .AutoFilter field:=4, Criteria1:="Luis"
     End With
End Sub

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论