View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Using Like Statement in Select Case

Great thanks!

"Jim Thomlinson" wrote:

Use InStr to return the position of "blah" within the string. Something like
this

Sub Test()
Dim str As String

str = "This and That"
Select Case True
Case InStr(1, str, "This")
MsgBox "Found this"
Case InStr(1, str, "That")
MsgBox "Found That"
Case InStr(1, str, "abcd")
MsgBox "Found ABCD"
End Select
End Sub

--
HTH...

Jim Thomlinson


"J@Y" wrote:

Is there a way to include Like in a Case?

Ie:

dim str as string

Select case str

(Case 1): If Str CONTAINS "blah"

end select

Its like writing If str like "*blah*" then... but with select case.