IF a cell contains a string
You can use OR()
to group expressions (as well as AND()
):
=IF(OR(condition1, condition2), true, false)
=IF(AND(condition1, condition2), true, false)
So if you wanted to test for "cat" and "22":
=IF(AND(SEARCH("cat",a1),SEARCH("22",a1)),"cat and 22","none")
SEARCH
does not return 0
if there is no match, it returns #VALUE!
. So you have to wrap calls to SEARCH
with IFERROR
.
For example...
=IF(IFERROR(SEARCH("cat", A1), 0), "cat", "none")
or
=IF(IFERROR(SEARCH("cat",A1),0),"cat",IF(IFERROR(SEARCH("22",A1),0),"22","none"))
Here, IFERROR
returns the value from SEARCH
when it works; the given value of 0
otherwise.