ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   IF-SEARCH (https://www.excelbanter.com/excel-worksheet-functions/5711-if-search.html)

Brook6

IF-SEARCH
 
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!

Jason Morin

=IF(ISNUMBER(SEARCH("-",A1)),"value_1","value_2")

HTH
Jason
Atlanta, GA

-----Original Message-----
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!
.


Harlan Grove

"Jason Morin" wrote...
=IF(ISNUMBER(SEARCH("-",A1)),"value_1","value_2")


Alternatives.

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

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




All times are GMT +1. The time now is 05:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com