VBA to select multiple values in Slicer (more than 24 line maximum)

kiki_lou

New Member
Joined
Feb 25, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
My slicer is a list of items codes. I recorded a macro to select the items for me, however when I surpass the 24 line maximum, the VBA no longer works.
I tried repeating the same code with different item #'s, but it unselects the first batch, and only selects the second batch. How would I rewrite the script below to select all item #'s showing?
Note that the Item list will constantly change (and could include up to 2000 items), I'm going to build something in excel that will allow the user to plug in their items, and then in turn it will give them the code to replace the below with.
I'm a newb (users even more so) when it comes to VBA, so need a simple solution that is user friendly.
Item code example: 100035591-001

Sheets("Slicer").Select
ActiveWorkbook.SlicerCaches("Slicer_StyleColorCode").VisibleSlicerItemsList = _
Array( _
"[Products].[StyleColorCode].&[100035591-001]", _
"[Products].[StyleColorCode].&[100035591-02F]", _
"[Products].[StyleColorCode].&[100035591-04J]", _
"[Products].[StyleColorCode].&[100035591-060]", _
"[Products].[StyleColorCode].&[100035591-0EE]", _
"[Products].[StyleColorCode].&[100035591-0IJ]", _
"[Products].[StyleColorCode].&[100035591-0ZB]", _
"[Products].[StyleColorCode].&[100035591-0ZG]", _
"[Products].[StyleColorCode].&[100035591-0ZH]", _
"[Products].[StyleColorCode].&[100035591-16X]", _
"[Products].[StyleColorCode].&[100035591-16Y]", _
"[Products].[StyleColorCode].&[100035591-1AZ]", _
"[Products].[StyleColorCode].&[100035591-1DP]", _
"[Products].[StyleColorCode].&[100035591-1F3]", _
"[Products].[StyleColorCode].&[100035591-1NN]", _
"[Products].[StyleColorCode].&[100035591-1TN]", _
"[Products].[StyleColorCode].&[100035591-1TW]", _
"[Products].[StyleColorCode].&[100035591-1TZ]", _
"[Products].[StyleColorCode].&[100035591-1U3]", _
"[Products].[StyleColorCode].&[100035591-1WD]")
Sheets("Slicer").Select
ActiveWorkbook.SlicerCaches("Slicer_StyleColorCode").VisibleSlicerItemsList = _
Array( _
"[Products].[StyleColorCode].&[100035591-1XN]", _
"[Products].[StyleColorCode].&[100035591-1ZD]", _
"[Products].[StyleColorCode].&[100035591-20A]", _
"[Products].[StyleColorCode].&[100035591-20F]", _
"[Products].[StyleColorCode].&[100036363-001]", _
"[Products].[StyleColorCode].&[100036363-00N]", _
"[Products].[StyleColorCode].&[100036363-060]", _
"[Products].[StyleColorCode].&[100036363-1UK]", _
"[Products].[StyleColorCode].&[100036363-1UL]", _
"[Products].[StyleColorCode].&[100036363-1W6]", _
"[Products].[StyleColorCode].&[100036409-322]", _
"[Products].[StyleColorCode].&[100036836-001]", _
"[Products].[StyleColorCode].&[100036836-00Z]", _
"[Products].[StyleColorCode].&[100036836-03U]", _
"[Products].[StyleColorCode].&[100036836-060]", _
"[Products].[StyleColorCode].&[100036836-06G]", _
"[Products].[StyleColorCode].&[100036836-0EW]", _
"[Products].[StyleColorCode].&[100036836-0WI]", _
"[Products].[StyleColorCode].&[100036836-0ZA]", _
"[Products].[StyleColorCode].&[100036836-17D]")
Sheets("Sheet1").Select
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,215,040
Messages
6,122,806
Members
449,095
Latest member
m_smith_solihull

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