Badr Hari
Badr Hari

Reputation: 8404

If else statement within formula using search

How can I use if else statements within excel formula if I use search? For just comparing a cell to a value, it is pretty straight forward, but not with search.

This is how I search if the there is a value in the cell:

=IF(ISNUMBER(SEARCH("AAA";L2)); "yes"; "no")

This would be the pseudo-code:

if (in cell L2 is BBB) {

 write "DONE!"

} else {

 if (in cell L2 is AAA) { // this is what my formula already does !
  write "yes"
 } else {
  write "no"
 }

}

Upvotes: 1

Views: 77

Answers (1)

Dmitry Pavliv
Dmitry Pavliv

Reputation: 35853

As I mentioned in comments, you can use following formula:

=IF(ISNUMBER(SEARCH("BBB";L2));"DONE!";IF(ISNUMBER(SEARCH("AAA";L2)); "yes"; "no"))

Upvotes: 1

Related Questions