Wild card in if then statements

  • Thread starter Thread starter jstocka
  • Start date Start date
J

jstocka

What is the proper application of a wild card in an "if
then" statement. I am trying to select by the first three
letters of a field. using the asterik after the three
letters does not work all my resources do not show any
examples. Any ideas??
thanks
 
Hi
try something like
If lcase(left(activecell.value,3))="abc" then
msgbox "starts with 'abc'"
end if
 
One way:

=IF(LEFT(Q11,3)="abc","good","bad")

Regards

Trevor
 
Not sure what you are looking for. Is this what you mean by a "wild card?"

Sub Demo()
If ActiveCell Like "[A-Z,a-z][A-Z,a-z][A-z,a-z]*" Then
MsgBox "Starts w/ 3 Letters"
End If
End Sub
 
jstocka said:
What is the proper application of a wild card in an "if
then" statement. I am trying to select by the first three
letters of a field. using the asterik after the three
letters does not work all my resources do not show any
examples. Any ideas??
thanks

This may not be what you need but you can grab the first three letters
of a cell w/ =Left(A1,3) This will give you the first 3 letters of
whatever is in cell A1 & then you can go from there.
 

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

Back
Top