Is it possible to test a cell using IF against multiple strings? So for example, I want the function to output Fruit in cell A2 if cell A1 contains the string Apple or Orange. I can only come up with this in cell A2:

IF(A1 = "Apple"|"Orange", "Fruit", "Not a fruit")

This results in an error.


This is thankfully quite easy. You can achieve what you want using the OR function in Numbers (this function is also found on Microsoft Excel):

IF(OR(A1 = "Apple", A1 = "Orange"), "Fruit", "Not a fruit")

The argument for the IF function here is OR(A1 = "Apple", A1 = "Orange"). This OR function tests whether any of the arguments are correct; if they are, it returns TRUE. If none of them are correct, it returns FALSE.

|improve this answer|||||

There is also this version :

IF(A1="Apple","Fruit",IF(A1="Orange","Fruit","Not a fruit"))

Which does not need OR() at all...

And this is one way of avoiding OR() and IF() using index and match... Cell B2 shows the function entered in cell B1.

enter image description here

|improve this answer|||||

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .