Select Case and Arrays?

hypnotoad

New Member
Joined
Feb 7, 2012
Messages
48
I'm trying to make a select case statement that would execute certain code depending on which array a user entered text string is stored in. I'm not using the code tag because I'm abbreviating (I hope that alright)...

Case Array1
do this
Case Array2
do this
etc...

I've tried a few ways of of writing the case statement, but Excel is not liking any of them. Is what I'm trying to do futile?
 
You're welcome. Thanks for the feedback.

Remark: you could, of course, reverse the logic:

Code:
...
 
Select Case True
 
    Case IsNumeric(Application.Match(sLookupValue, vArr1, 0))
        sOption = "One"
 
...
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Yeah that's pretty neat! I probably would know these things but I have no formal training in any programming language. Thanks again, I really appreciate it.
 
Upvote 0
A slightly different approach
Code:
Sub anotherway()
    
    Select Case Sheets("List").Cells(2, 1).CurrentRegion.Find(UserForm1.tag, Lookat:=1).Column
        Case Is = 1: MsgBox ("Array1")
        Case Is = 2: MsgBox ("Array2")
        Case Is = 3: MsgBox ("Array3")
    End Select
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,266
Messages
6,183,930
Members
453,196
Latest member
ABHISHEK_3887

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