Search within a single cell for a character

A

AZSteve

Using VBA I want an If/Then statement to search within a single cell (D59) to
find if the ":" (colon character) exists after the fourth character. If not
"Then: Wrong = True"

In an adjacent worksheet cell I could just enter =iserr(find(":",D59,4)) and
if the result is True then I know it doesn't exist.

How do I write this in VBA?
 
B

B Lynn B

Dang, I really need to learn to read the details more carefully before
posting my reply. This actually should have been:

If InStr(5, Range("D59"), ":") = 0 Then Wrong = True

or

If Not InStr(5, Range("D59"), ":") > 0 Then Wrong = True

but you probably got the idea anyhow...
 

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