Excel OR function
The OR function in Excel is used to test multiple conditions at the same time, if any one of the conditions is met, a TRUE is returned, if none of the conditions is met, a FALSE is returned. The OR function can be used in combination with the AND and IF functions together.
The syntax for the OR function in Excel is:
Test multiple conditions, return TRUE if any one of arguments is met, if not, return FALSE.
Let’s take the below data for example:
|Cell C4: =OR(A4,B4)||TRUE||Displays TRUE because the first argument is true.|
|Cell C5: =OR(A5>60,B5<20)||FALSE||Displays FALSE because both criteria do not match.|
|Cell C6: =OR(2+5=6,20-10=10,2*5=12)||TRUE||Displays TRUE because the condition “20-10” is matching.|
In Excel, you may need to combine the AND and OR function together for solving some problems, there are some basic patterns as follows:
- =AND(OR(Cond1, Cond2), Cond3)
- =AND(OR(Cond1, Cond2), OR(Cond3, Cond4)
- =OR(AND(Cond1, Cond2), Cond3)
- =OR(AND(Cond1,Cond2), AND(Cond3,Cond4))
For example, if you want to know the Product which are KTE and KTO, the order of KTE is greater than 150, and the order of KTO is greater than 200.
Please use this formula, and then drag the fill handle to the cells you want to apply this formula, and you will get the result as below screenshot shown:
This example helps you to understand the combination of OR and IF functions. For example, you have a table contains the students’ test score, if one of the subjects is greater than 60, the student will pass the final exam, otherwise, fail the exam. See screenshot:
To check if the student passes the exam or not, using the IF and OR functions together to solve it, please use this formula:
This formula indicates that, it will return Pass, if any a value in column B or column C is equal or greater than 60. Otherwise, the formula returns Fail. See screenshot:
If we you OR as an array formula, you can test all values in a specific range against a given condition.
For example, if you want to check if there are values in a range are greater than 1500, please use the below array formula, and then press Ctrl +Shift + Enter keys together, it will return TRUE if any cell in A1:C8 is greater than 1500, otherwise, FALSE is returned. See screenshot: