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
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