change pivot filter using comma separated list - vba

kdu23

New Member
Joined
Aug 15, 2018
Messages
3
Hi can anyone tell me if it is possible to set a pivot table filter in vba using a comma separated list?
I have the following code which populates specified cells on a worksheet with listbox selections. I then need to take those selections and apply them as filters to the base data - I assumed that using a pivot table would be the easiest option but I dont really care as long as I can filter the data.
Thanks for any help :)




Dim change_pivot_table_Territory
Dim change_pivot_table_Store
Dim change_pivot_table_brand


'assign active cell to previously populated cell - comma separated list and apply to pivot filters
Sheets("Workings").Select
Range("F1").Select
change_pivot_table_Territory = ActiveCell.Value
ActiveSheet.PivotTables("PivotTable1").PivotFields("Territory").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Territory").EnableMultiplePageItems = True
ActiveSheet.PivotTables("PivotTable1").PivotFields("Territory").CurrentPage = change_pivot_table_Territory


Range("F2").Select
change_pivot_table_Store = ActiveCell.Value
ActiveSheet.PivotTables("PivotTable1").PivotFields("Store").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Store").EnableMultiplePageItems = True
ActiveSheet.PivotTables("PivotTable1").PivotFields("Store").CurrentPage = change_pivot_table_Store


Range("F3").Select
change_pivot_table_brand = ActiveCell.Value
ActiveSheet.PivotTables("PivotTable1").PivotFields("BRAND2").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("BRAND2").EnableMultiplePageItems = True
ActiveSheet.PivotTables("PivotTable1").PivotFields("BRAND2").CurrentPage = change_pivot_table_brand

ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,222,830
Messages
6,168,507
Members
452,194
Latest member
Lowie27

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top