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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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