Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using Like Statement in Select Case
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using Like Statement in Select Case
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Select Case Statement | Excel Worksheet Functions | |||
For...Next or Select Case Statement | Excel Programming | |||
select case statement? | Excel Programming | |||
Select Case within IF-Else statement | Excel Programming | |||
select case statement | Excel Programming |