IF-SEARCH

G

Guest

I want to search a text/number string to see if it has a dash "-" and if it
does, I want to insert a value and if it doesn't, I want a different value

I tried...
IF(SEARCH("-",A2)>0
....which works fine if the string does have a dash, but bombs to #VALUE!
errror if the string does not have a dash

Any help appreciated!
 
H

Harlan Grove

Jason Morin said:
=IF(ISNUMBER(SEARCH("-",A1)),"value_1","value_2")

Alternatives.

=IF(COUNTIF(A1,"*-*"),"Yay!","Boo!")

=IF(SUBSTITUTE(A1,"-","")<>A1,"Yay!","Boo!")
 

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