Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case with variables

Status
Not open for further replies.

Chopstik

Technical User
Oct 24, 2001
2,180
0
0
US
Is it possible to do a select case statement with variables in the Case piece?

For example, I might have several cases that begin with "Property", like "Property_Summary" or "Property_Location" but that would really be the same thing (need the same code from the Case statement). So, what I'm wondering is if it is possible to do the following:

Select Case Screen
Case Property*
'Run code here
Case Location*
'Run code here
Case Else
'Run other code here
End Select

where Property* is anything that begins with Property. TIA! Insanity is merely a state of mind while crazy people have a mind of their own.
 
Try this:

Public sub Select_case()
Dim strSelect As String

strSelect = "Property_HELP"

Select Case strSelect
Case "Property_A" To "Property_zzzzzzzzzzzzz"
msgbox "property_selected"
Case Else
msgbox "nothing selected"
End Select

End Function
 
Thanks... Hadn't thought about it that way. Will test it when I return to the office. Insanity is merely a state of mind while crazy people have a mind of their own.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top