OR function
The OR function in Excel is a logical function that returns TRUE if any of the conditions (arguments) it evaluates are TRUE, and FALSE if all conditions are FALSE. It’s typically used to check multiple conditions at once and see if at least one of them is met.
Syntax:
=OR(logical1, logical2, ...)
- logical1, logical2, …: These are the conditions or logical tests you want to check. You can include up to 255 logical conditions.
Example 1:
If you want to check whether either of two conditions is TRUE, for instance, if the value in cell A1 is greater than 10 or if the value in B1 is less than 5, you can use:
=OR(A1 > 10, B1 < 5)
- If either
A1 > 10orB1 < 5isTRUE, the function will returnTRUE. - If both conditions are
FALSE, it will returnFALSE.
Example 2:
Check if a value in cell C1 is equal to 20 or 30:
=OR(C1 = 20, C1 = 30)
- If
C1is either 20 or 30, it will returnTRUE. - If
C1is neither, it will returnFALSE.
Example 3:
Use OR in an IF statement. For example, if you want to assign a grade of “Pass” if either score in D1 is greater than or equal to 50 or the score in E1 is greater than or equal to 50:
=IF(OR(D1 >= 50, E1 >= 50), "Pass", "Fail")
- This will return “Pass” if either score is 50 or higher; otherwise, it will return “Fail”.
Benefits:
- Multiple conditions: You can check several conditions at once, making it more efficient for complex decision-making.
- Flexibility: It works well with
IFand other logical functions to create complex formulas for various scenarios.