search returns error when substring not found

D

David Schwartz

I want to set a cell to "A" if a string is found in another cell and
"B" if the string is not found. I'm currently using the SEARCH
function as follows.

IF(SEARCH("Overview",A1) > 0, "A", "B")

The problem is that the IF unction returns #VALUE! when the argument
is #VALUE! which is the result of an unsuccessful search. I've tried
to test the result using the ERROR.TYPE function but that just returns
#N/A when the string is found.

Ideally, SEARCH would return '0' when the string isn't found but that
doesn't appear to be the case.

Any thoughts how I can accomplish this?

TIA,
David
 
P

Pete_UK

Try it this way:

IF(ISNUMBER(SEARCH("Overview",A1)), "A", "B")

Hope this helps.

Pete
 

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