totn Excel Functions

MS Excel: How to use the OR Function (WS)

This Excel tutorial explains how to use the Excel OR function with syntax and examples.

Description

The Microsoft Excel OR function returns TRUE if any of the conditions are TRUE. Otherwise, it returns FALSE.

The OR function is a built-in function in Excel that is categorized as a Logical Function. It can be used as a worksheet function (WS) in Excel. As a worksheet function, the OR function can be entered as part of a formula in a cell of a worksheet.

Please read our OR function (VBA) page if you are looking for the VBA version of the OR function as it has a very different syntax.

Syntax

The syntax for the OR function in Microsoft Excel is:

OR( condition1, [condition2, ... condition_n] )

Parameters or Arguments

condition1
A condition to test that can either be TRUE or FALSE.
condition2, ... condition_n
Optional. Conditions to test that can either be TRUE or FALSE. There can be up to 30 conditions.

Returns

The OR function returns TRUE if any of the conditions are TRUE.
The OR function returns FALSE if all conditions are FALSE.

Applies To

  • Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000

Type of Function

  • Worksheet function (WS)

Example (as Worksheet Function)

Let's look at some Excel OR function examples and explore how to use the OR function as a worksheet function in Microsoft Excel:

Microsoft Excel

Based on the Excel spreadsheet above, the following OR examples would return:

=OR(A1<10, A1=40)
Result: FALSE

=OR(A1=30, A2="Microsoft")
Result: TRUE

=OR(A1>=5, A1=20, A2="techonthenet.com")
Result: TRUE

Frequently Asked Questions

Question: In Microsoft Excel, I'm trying to use the If function to return 0 if cell A1 is either < 150,000 or > 250,000. Otherwise, it should return A1.

Answer: You can use the OR function to perform an OR condition in the If function as follows:

=IF(OR(A1<150000,A1>250000),0,A1)

In this example, the formula will return 0 if cell A1 was either less than 150,000 or greater than 250,000. Otherwise, it will return the value in cell A1.


Question: I have been looking at your Excel IF, AND and OR sections and found this very helpful, however I cannot find the right way to write a formula to express if C2 is either 1,2,3,4,5,6,7,8,9 and F2 is F and F3 is either D,F,B,L,R,C then give a value of 1 if not then 0. I have tried many formulas but just can't get it right, can you help please?

Answer: You can write an IF statement that uses the AND function and the OR function as follows:

=IF(AND(C2>=1,C2<=9, F2="F",OR(F3="D",F3="F",F3="B",F3="L",F3="R",F3="C")),1,0)

Question:I have a nesting OR function problem:

My nonworking formula is:

=IF(C9=1,K9/J7,IF(C9=2,K9/J7,IF(C9=3,K9/L7,IF(C9=4,0,K9/N7))))

In Cell C9, I can have an input of 1, 2, 3, 4 or 0. The problem is on how to write the "or" condition when a "4 or 0" exists in Column C. If the "4 or 0" conditions exists in Column C I want Column K divided by Column N and the answer to be placed in Column M and associated row

Answer:You should be able to use the OR function within your IF function to test for C9=4 OR C9=0 as follows:

=IF(C9=1,K9/J7,IF(C9=2,K9/J7,IF(C9=3,K9/L7,IF(OR(C9=4,C9=0),K9/N7))))

This formula will return K9/N7 if cell C9 is either 4 or 0.