Opposite of "Like" in VBA

  • Thread starter Thread starter Ryan
  • Start date Start date
R

Ryan

I have created a function (code below) however I want to change the "Like"
part to "not like" however this does not work. Can someone please advise what
the statement should be i.e the opposite of "Like". Thanks (from someone who
has been experimenting with VBA for 1 week)

Function One3Numbers(NumCalled As Variant) As Variant
If NumCalled Like "13*" Then
One3Numbers = "a 13 number"
Else
One3Numbers = "is not a 13 number"
End If
End Function
 
Use:
If Not NumCalled Like "13*" Then

However, remember to handle Nulls. A Null doesn't match anything: it isn't
like anything, and it doesn't evaluate to true when you ask if it's not like
anything. See Errors 5 and 6 in this article:
Common errors with Null
at:
http://allenbrowne.com/casu-12.html
 

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