VBA code size to select slicers

Davek81

New Member
Joined
Aug 19, 2014
Messages
7
Hi All, after a bit of help to reduce the number of lines of code due to getting a procedure too large error. I have a slicer that has say approx 70 selectable options. The code basically says when a cell = something then select this slicer, however the code each time is 70 lines long as it states the one you require as true then the rest listed as false. Please see below code, how can I shrink this????

ElseIf Sheets("Dashboard").Range("N3") = "This is Test Code" Then
Sheets("Dashboard").Select
With ActiveWorkbook.SlicerCaches("Slicer_Supplier")
.SlicerItems("This is Test Code").Selected = True
.SlicerItems("#N/A").Selected = False
.SlicerItems("Blah Blah").Selected = False
.SlicerItems("Blah Blah").Selected = False
.SlicerItems("Blah Blah").Selected = False
.SlicerItems("Blah Blah").Selected = False
.SlicerItems("Blah Blah").Selected = False

and so on.........

Any help greatly appreciated
 

Forum statistics

Threads
1,226,840
Messages
6,193,274
Members
453,788
Latest member
drcharle

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