Numbers – How to Check if Cell Equals X or Y

numbers

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.

Best Answer

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.