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.