Wild card in if then statements

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
 
F

Frank Kabel

Hi
try something like
If lcase(left(activecell.value,3))="abc" then
msgbox "starts with 'abc'"
end if
 
D

Dana DeLouis

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
 
J

Josh

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.
 
Top