vba autofilter with variable array

TMal830

New Member
Joined
Sep 24, 2013
Messages
12
Hello,

I've looked all over and can't find an answer to this, somewhat new to this so please excuse any lack of information.

I've created a userform listbox that someone can use to pick multiple selections. Once you press the "Next" command button, an array of the selections chosen in the listbox is created under the variable "regionarray". This array can include between 1 and 9 selections. An example is "Northwest, Southwest, North Central". Id like to be able to autofilter my worksheet with this array name, but I'm not getting anywhere. I've tried putting each selection in quotations as you typically would if no variable was involved, and still no luck. Also attempted changing the quotations to "chr" characters, same result. Is it possible to filter based on an array name? If so, could someone give an example?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi,
I assume that you have declared your array as String and not another data type?
Also as a suggestion, perhaps using Split may do what you want

Code:
regionarray = "Northwest, Southwest, North Central"
AutoFilter Field:=1, Criteria1:=Split(regionarray, ","), Operator:=xlFilterValues

Dave
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

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