Slicer Filter based on cell value

deadlyliquidx

New Member
Joined
Feb 6, 2015
Messages
27
Hello All,
I have a code that filters a olap based pivot table Slicers based on cell values in column A.
Code:
Sub SetSelection()
    Dim sc As SlicerCache
    Dim s As Slicer
    Set sc = ActiveWorkbook.SlicerCaches("Slicer_location") ' Name of slicer
     Set s = sc.Slicers(1)
    sc.VisibleSlicerItemsList = Array(ActiveSheet.Range("a1"), ActiveSheet.Range("a2:a2"), ActiveSheet.Range("a3:a3"))
End Sub
Problem is at "sc.VisibleSlicerItemsList = Array(ActiveSheet.Range("a1"), ActiveSheet.Range("a2:a2"), ActiveSheet.Range("a3:a3"))".
You see, exactly a1,a2,a3 has to have a slicer value.
If there is a blank, I get an error message.
IDEALLY, I would like to loop through column A (a1:A300) and stop when there is a blank.
And also instead of having to put range a1, range a2, range a3, i would like to have it just go through the whole named range storelist (a1:a300)

Basically I want it to go through the cells in column A and assign the value to the slicer until it hits the blank.

Thanks alot!!!
I would have provided a worksheet but my data is OLAP data so there is no connection.
 

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,215,020
Messages
6,122,709
Members
449,093
Latest member
Mnur

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