OR Function Examples IF OR Statements – Excel & Google Sheets
Written by
Reviewed by
Download the example workbook
This tutorial demonstrates how to use the OR Function in Excel and Google Sheets to test if one or more criteria is true.
What is the OR Function?
The OR Function tests if one or more conditions are TRUE. It can evaluate up to 255 expressions.
How to Use the OR Function
Use the Excel OR Function like this:
=OR(C3="Pop", C3="Rock")
If the text in column C is equal to “Pop” or “Rock”, OR will return TRUE. Anything else will return FALSE.
Compare Text
Note that text comparisons are not case-sensitive. So the following formula would produce the same results as above:
=OR(C3="POP", C3="ROCK")
Also, OR does not support wildcards. So this formula returns FALSE:
=OR(C3="P*", C3="R*")
This is because OR will literally compare the text string “P*” and “R*” with the value in C3.
Compare Numbers
You have a range of comparison operators at your disposal when comparing numbers. These are:
For example, if you had a list of 1980s movies and wanted to find ones from 1983 and earlier, or 1987 and later, you could use this formula:
=OR(C3<=1983, C3>=1987)
If one of the expressions in OR is a number by itself without a comparison operator, such as =OR(1983), OR will return TRUE for that value, except if the number is zero, which evaluates to FALSE.
Using OR with Other Logical Operators
You can combine OR with any of Excel’s other logical operators, such as AND, NOT, and XOR.
Here’s how you might combine it with AND. Imagine we have a table with data on some movies. We want to find movies released after 1985 that were directed by either Steven Spielberg or Tim Burton. We could use this formula:
=AND(C3>1985,OR(D3="Steven Spielberg",D3="Tim Burton"))
When you combine logical operators in this way, Excel works from the inside-out. So it will evaluate the OR statement here first, since that’s nested within the AND.
Using OR with IF
OR is most commonly used as part of a logical test in an IF statement.
Use it like this:
=IF(OR(C3="CA", D3>300),D3*0.05,0)
Imagine we’re running some new promotions. To help us break into the California market, we’re offering a 5% discount in that state. We’re also offering 5% off any order over $300, to encourage our customers to make bigger orders.
The IF statement evaluates our OR Function first. If returns TRUE, IF will return D3*0.05, which give us the 5% discount value. If not, it returns 0: the order didn’t meet our criteria, so we don’t apply the discount.
OR in Google Sheets
The OR Function works exactly the same in Google Sheets as in Excel:
OR Examples in VBA
You can also use the OR function in VBA. Type:
Application.Worksheetfunction.Or(logical1,logical2)
For the function arguments, you can either enter them directly into the function, or define variables to use instead.