How can I assign a value to cells if it's neighbour contains a specific string?
For example, fields in column A:
dog11
cat22
cow11
chick11
duck22
cat11
horse22
cat33
The syntax in column B would be:
=IF(SEARCH("cat",A1),"cat",IF(SEARCH("22",A1),"22","none"))
It always picks up the first TRUE cell, but drops when the value is not true.
This question is related to
excel
if-statement
contains
=IFS(COUNTIF(A1,"*cats*"),"cats",COUNTIF(A1,"*22*"),"22",TRUE,"none")
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")
Source: Stackoverflow.com