"like" and "not like" comparison

H

Henry

I want to search a list of names, and I want to exclude any names like like
"NY." I know how to do this include names like "NY", but can't find any help
on "not like" expression. Thanks for your help.

Function NYTest(abc)
If abc = "NY" Then
NYTest = "NY"
Else: NYTest = "UNK"
End If

End Function
 
D

Dirk Goldgar

Henry said:
I want to search a list of names, and I want to exclude any names like like
"NY." I know how to do this include names like "NY", but can't find any
help
on "not like" expression. Thanks for your help.

Function NYTest(abc)
If abc = "NY" Then
NYTest = "NY"
Else: NYTest = "UNK"
End If

End Function


I'm not sure I understand you, because the code snippet you posted doesn't
use the Like operator at all. However, in principle you can use tests like
these:

Test for "like":

If abc Like "*NY*" Then
' abc contains the string "NY"
End If

Test for "not like":

If Not (abc Like "*NY*") Then
' abc does not contain the string "NY"
End If
 

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