case is string contains string?

S

salgud

I have played with it for an hour, but can't figure out how to make a case
statement that would be something like:

Case is = (string1 contains string2)

Is there a way to do this?
Thanks!
 
G

Gary Keramidas

simplistic, but may give you an idea, since you didn't provide much.

Sub test()
Select Case True
Case InStr(1, "this is a test", "tst")
Debug.Print "True"
Case Else
Debug.Print "False"
End Select
End Sub
 
S

salgud

I have played with it for an hour, but can't figure out how to make a case
statement that would be something like:

Case is = (string1 contains string2)

Is there a way to do this?
Thanks!

Thanks to all!
 
S

salgud

Thanks to all!

Gave both methods a try, but neither works! I'm setting a case for
worksheets that have "Monthly" in their sheetname (sWsName)

I put in:

Case sWsName like "Monthly"

and

Case "Monthly" Like sWsName

and

Case instr(1,lcase(sWsName),"monthly")

and

Case InStr(1, sWsName, "Monthly")

Am I missing something?
 
B

Bob Phillips

Not much point us answering if you don't read it

Case sWsName like "*Monthly*"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top