The OR function is one of Excel’s logical functions that allows you to test multiple conditions at the same time OR returns TRUE if any of the conditions evaluate to TRUE, and FALSE if all conditions evaluate to FALSE. The OR function is extremely useful for expanding the functionality of Excel’s other logical and lookup functions
In this comprehensive guide, we will cover everything you need to know to use the OR function effectively in your Excel worksheets, including:
- What the OR Function Does
- OR Function Syntax and Arguments
- Practical Examples of Using OR
- Combining OR with Other Functions Like IF, AND, NOT
- Using OR with Conditional Formatting and Data Validation
- Notes and Tips for Using OR
What Does the OR Function Do?
The purpose of OR is to test multiple conditions or criteria simultaneously and return TRUE if any of them are true, Some examples of using OR
- =OR(A1>10, A1<5) – Returns TRUE if A1 is greater than 10 OR less than 5
- =OR(A1>0, B1>0) – Returns TRUE if A1 or B1 is greater than 0
- =OR(A1=”Yes”, B1=”No”) – Returns TRUE if A1 is “Yes” OR B1 is “No”
The OR function can take up to 255 logical tests or conditions as arguments. As long as any one of the tests evaluates to TRUE, the overall OR function will return TRUE. If all arguments provided evaluate to FALSE, the OR function will return FALSE.
This ability to “bundle” multiple tests into one logical expression is what makes OR so useful.
OR Function Syntax
The syntax for the OR function is:
=OR(logical1, [logical2], ...)
Where:
logical1
– The first condition to test. Required.logical2
– The second condition to test. Optional, up to 255 conditions allowed.
The arguments for OR can include:
- Logical values like TRUE and FALSE
- Numbers like 1 and 0 (where 0 is FALSE)
- Cell references
- Comparisons and expressions that evaluate to TRUE or FALSE
- Other functions that return TRUE or FALSE
Examples of Using the OR Function
Let’s look at some examples of using OR on its own and together with other functions:
Simple OR Examples
Test if A2 is greater than 1 OR less than 100:
=OR(A2>1,A2<100)
Displays TRUE if A2 is greater than 1 OR less than 100, else FALSE.
Test for multiple values with OR:
=OR(A2=10,A2=20,A2=30)
TRUE if A2 is equal to 10, 20 OR 30. FALSE for any other value.
OR with the IF Function
IF statements are commonly nested inside OR:
=IF(OR(A1>10,A1<5),"Outside range","Within range")
If A1 is greater than 10 OR less than 5, return “Outside range”, else return “Within range”.
Here the OR function expands what would otherwise require nested IFs.
OR with AND
Combine AND and OR to create more complex logical expressions:
=IF(AND(OR(A1=5,A1=10),B1>1000),"Valid","Invalid")
In this case both criteria must be true: A1 must be 5 OR 10, and B1 must be greater than 1000.
Using OR with Conditional Formatting
OR is frequently used in conditional formatting rules. For example:
=OR(A1="Yes",A1="Approved")
This will highlight cells that contain exactly “Yes” or “Approved”.
Data Validation with OR
The OR function can also be used in data validation to restrict cells to a predefined list of values.
For example, if you want to allow only “Yes”, “No”, or “Maybe” to be entered in a cell, use:
=OR(A1="Yes",A1="No",A1="Maybe")
This will throw an error if anything besides those 3 options is entered.
Tips for Using the OR Function
Here are some additional notes and tips for using OR effectively:
- OR is not case-sensitive, “yes” = “YES”
- Numbers are evaluated as TRUE except for 0 which is FALSE
- Text values and empty cells are ignored
- Use Ctrl + Shift + Enter to enter OR formulas as arrays
- Watch out for errors like #VALUE! if no logical values are found
- OR can’t be used in array formulas returning multiple values
- OR will short-circuit and stop reading arguments after finding the first TRUE
Common Uses for the OR Function
Some of the most common uses for OR in Excel include:
- Testing if a value equals X or Y
- Checking if a date falls on the weekend
- Flagging records that meet certain criteria
- Showing a message if input is invalid
- Making sure all required values are entered
- Detecting errors in a dataset
- Creating dynamic ranges that expand based on criteria
- Building conditional formatting rules
By combining OR with functions like IF, AND, VLOOKUP, and COUNTIFS, you can create some very powerful logic in Excel worksheets.
The OR function is one of Excel’s most useful logic functions for testing multiple conditions at the same time. Use it to simplify formulas and validate data.
In Summary
The OR function allows logical “this or that” testing in Excel formulas. Key points:
- Test up to 255 conditions at once
- Returns TRUE if any argument is TRUE
- Commonly combined with IF, AND, VLOOKUP
- Useful for conditional formatting and data validation
- Can create complex logic when nested
Knowing how and when to use the OR function will help you write more efficient and robust Excel formulas.
What is the OR Function?
The OR Function[1] is categorized under Excel LOGICAL functions. The function will determine if any of the conditions in a test is TRUE.
In financial analysis, the OR function can be useful in comparing two statements or two values. For example, A1 for either “a” or “b,” use =OR(A1=”a”,A1=”b”). The function can be used as the logical test inside the IF function to avoid extra nested IFs, and can be combined with the AND function.
=OR(logical1, [logical2], …)
The function uses the following arguments:
- Logical1 (required argument) – This is the first condition or logical value to evaluate.
- Logical2 (optional argument) – The second condition or logical value to evaluate.
Video Tutorial – OR Function in Excel
To learn more about using the OR Function in Excel, check out the video below:
Excel Tutorial for Beginners
Why should you use Microsoft Excel?
Microsoft Excel is used by millions of users worldwide. And for good reason. Excel is a powerful spreadsheet database that does a lot more than just help you store data. From financial analysis to customer information, Excel can be an essential tool for any business managing cross-functional departments.
Which symbol is used in Excel?
The most commonly used symbol in Excel is the equal ( =) sign. Every single formula or function used has to start with equals to let Excel know that a formula is being used. If you wish to reference a cell in a formula, it has to have an equal sign before the cell address. Otherwise, Excel just shows the cell address as standard text.
What is a formula in Excel?
The formula references a cell that no longer exists. The value is too wide to fit within its column. Learn and remember key functions, formulas, and shortcuts for Excel with this handy quick reference guide (+ PDF) to the fundamentals of Excel.