pivot table filter using list on separate sheet

I have a pivot table set up exactly how it needs to be, however the ID column is pretty extensive so I am looking to have a macro that easily filters only the IDs that I want for the pivot table. What I would like to do is be able to run a macro which looks at all the IDs I have on sheet2 and goes to my pivot table on sheet1 and only shows those IDs.

I have really been searching to see what other similar topics mentioned. But either those questions and solutions did not apply to what I am trying to do, or they are way over my head that I did not even realize what was occurring in the code. My initial thought was to record a macro where I would select a few IDs to see what the code looked like and then change the IDs on the macro to the cells on sheet2 where my IDs are; that did not work for me so I'm not sure if it was a good idea and bad execution or if I am just way off base right now. But here is the code I have so far:

Sub report_filter_macro()
'
' report_filter_macro Macro
' filter only the IDs desired

    ActiveSheet.PivotTables("my_pivot").PivotFields("IDs").CurrentPage = _
        "(All)"
    With ActiveSheet.PivotTables("my_pivot").PivotFields("IDs")
        .PivotItems("000022").Visible = False ' does not show ID 000022 in the pivot table
        .PivotItems("000011").Visible = False ' does not show ID 000011 in the pivot table
    End With
    ActiveSheet.PivotTables("my_pivot").PivotFields("IDs"). _
        EnableMultiplePageItems = True ' allows multiple filters
End Sub

Thank you for any help on this.

Answers


Need Your Help

C# Problem with Oauth

c# oauth

I am trying to create oauth signature. But I dont know what I am doing wrong because the site giving unauthorize error. I am using oauth version 1.0. Method is HMAC-SHA1 and it is google based oaut...

C++ Factory Pattern with Heterogenous Constructor Constraint

c++ templates boost dispatcher factory-pattern

I'm implementing a C++ program that can programmatically instantiate objects given an input file which provides the class names and arguments to pass to the constructors.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.