## How to use the OR function

The OR function allows you to carry out a logical test in each argument and if at least one argument returns TRUE the OR function returns TRUE.

If all arguments return FALSE the OR function also returns FALSE.

Formula in cell D3:

The picture above shows the formula in column D, it returns TRUE in cell D3, D4 and D5 because the amount is below 10.

### Table of Contents

## 1. OR function syntax

OR(*logical1*, *[logical2]*)

The or function is a logical function, it allows you to evaluate multiple conditions.

It can be used instead of nested IF functions. The OR function is even more versatile if you combine it with the AND function, there is an example below using both the OR and AND functions.

## 2. OR function arguments

logical1 |
Required. A logical expression that returns a logical value or a number. |

[logical2] |
Optional. You can have up to 254 additional arguments. |

## 3. Boolean arguments

The OR function arguments can result in TRUE or FALSE, however, it also treats all numbers, both positive and negative, as TRUE.

The exception to that is 0 (zero) which is treated the same as FALSE.

Formula in cell B3:

Formula in cell B3 returns TRUE. TRUE exists at least once.

Formula in cell B4:

Formula in cell B4 returns TRUE.

Formula in cell B5:

Formula in cell B4 returns FALSE. All arguments are FALSe, OR function returns FALSE.

Formula in cell B6:

The numerical equivalent to TRUE is any number other than 0 (zero). 1 is therefore TRUE. Formula in cell B6 returns TRUE.

Formula in cell C3:

The same goes for negative values. -1 is TRUE.

Formula in cell C3:

23, 55 and -34 are all TRUE.

Formula in cell C3:

0 (zero) is FALSE. All arguments are FALSE, OR function returns FALSE.

Formula in cell C3:

All numbers are not zero, they all evaluate to TRUE.

## 4. OR function - multiple conditions

The array formula in cell C3 performs two logical tests. If the value in cell B3 is equal to cell E3 or E4 the formula returns TRUE.

Formula in cell C3:

The technique used in column C that compares a value to multiple values using a cell range instead of declaring each logical expression in an argument saves you time and effort. The downside is that you need to enter the formula as an array formula unless you use Excel 365.

To enter the formula above as an array formula, type the formula in a cell. Press and hold CTRL + SHIFT keys simultaneously, then press Enter once. Release all keys.

The formula is now enclosed with curly brackets, they indicate you successfully entered the formula as an array formula. Don't enter the curly brackets yourself.

### 4.1 Explaining formula in cell C3

#### Step 1 - Reference conditions

You will be using the same conditions in cell C3 and cells below, it is a good idea to create absolute references meaning they won't change when you copy the cell and paste to cells below.

The dollar sign $ lets you lock both column and row references, see reference below.

$E$3:$E$4

returns {"Binder";"Printer"}. The curly brackets tell you that this is an array of values, they can have a comma or semicolon delimiting character or both.

#### Step 2 - Compare conditions with cell value

The equal sign is a logical operator that lets you compare value to value or in this case value to values. It returns a boolean value TRUE or FALSE.

$E$3:$E$4=B3

becomes

{"Binder";"Printer"}="Stapler"

and returns {FALSE; FALSE}. None of the conditions match the value in cell B3.

#### Step 3 - Evaluate OR function

The OR function returns TRUE if at least one of the boolean values in the array is TRUE.

OR($E$3:$E$4=B3)

becomes

OR({FALSE; FALSE})

and returns FALSE.

## 5. OR function not working

The OR function returns an error value if it's not working properly. Press with the mouse on the exclamation mark and a pop-up menu appears.

Press with the mouse on "Help on this error". It will take you to the Microsoft website where you can troubleshoot the formula further.

### 5.1 #NAME! error

The name error occurs if you misspelled a function. Check the formula in the formula bar. In the example above the OR function is wrong.

### 5.2 Calculation

Check that the calculation options are set to automatic.

Go to top formulas. On the ribbon. Press with left mouse button on the calculation options button. A pop-up menu appears, select "Automatic".

### 5.3 #VALUE! error

Formula in cell D3:

The or function returns a value error if one of the arguments is not a Boolean value or numerical value.

## 6. OR function array

The array formula in cell D3 evaluates two logical expressions. If the value in cell B3 is equal to any of the conditions in cells B9:B11 **and** the value in cell C2 is equal to any of the numbers in cells C9:C10 the formula returns TRUE.

Formula in cell D3:

Cell B3 is equal to a condition in cell B9 and cell C3 is equal to C10, the formula returns TRUE in cell D3.

### 6.1 Explaining formula in cell C3

#### Step 1 - Compare values

The equal sign is a logical operator that lets you compare value to value or in this case value to values. It returns a boolean value TRUE or FALSE.

$B$9:$B$11=B3

becomes

{"Stapler";"Calculator";"Ballpoint pen"}="Stapler"

and returns

{TRUE; FALSE; FALSE}.

#### Step 2 - Check if any of the conditions match cell B3

The OR function returns TRUE if at least one of the boolean values in the array is TRUE.

OR($B$9:$B$11=B3)

becomes

OR({TRUE; FALSE; FALSE})

and returns TRUE.

#### Step 3 - Check next cell C3

OR($C$9:$C$10=C3)

becomes

OR({19;2}=2)

becomes

OR({FALSE; TRUE})

and returns TRUE.

#### Step 4 - Check that all conditions evaluate to TRUE

The AND function returns TRUE if all arguments evaluate to TRUE.

AND(OR($B$9:$B$11=B3),OR($C$9:$C$10=C3))

becomes

AND(TRUE, TRUE)

and returns TRUE.

## 7. OR function COUNTIF

The array formula in cell D3 evaluates two logical expressions. If the value in cell B3 is equal to any of the conditions in cells B9:B11 **or** the value in cell C3 is equal to any of the numbers in cells C9:C11 the formula returns TRUE.

Formula in cell D3:

Cell B3 is equal to a condition in cell B9 and cell C3 is not equal to any of the conditions in cells C9:C11, the formula returns TRUE in cell D3.

### 7.1 Explaining formula in cell C3

#### Step 1 - Count values based on first conditions

The COUNTIF function counts the number of cells that meet the condition.

COUNTIF(*range*, *criteria*)

COUNTIF(B3,$B$9:$B$11)

becomes

COUNTIF("Stapler", {"Stapler"; "Calculator"; "Ballpoint pen"})

and returns {1; 0; 0}.

#### Step 2 - Count values based on second conditions

COUNTIF(C3,$C$9:$C$11)

becomes

COUNTIF(2, {19; 3; 8})

and returns {0; 0; 0}.

#### Step 3 - Count values

The OR function returns TRUE if at least one value is TRUE.

OR(COUNTIF(B3,$B$9:$B$11), COUNTIF(C3,$C$9:$C$11))

becomes

OR({1; 0; 0}, {0; 0; 0})

and returns TRUE. 1 is the numerical equivalent to TRUE.

## 8. OR function with IF

Formula in cell D3:

### 8.1 Explaining formula in cell C3

#### Step 1 - Check the first condition

The larger than character is a logical operator, it checks if a value is larger than another value. It returns boolean value TRUE or FALSE.

C3>5

becomes

11>5

and returns TRUE.

#### Step 2 - Check the second condition

The smaller than character is a logical operator, it checks if a value is smaller than another value. It returns boolean value TRUE or FALSE.

C3<1

becomes

11<1

and returns FALSE.

#### Step 3 - Evaluate OR function

OR(C3>5,C3<1)

becomes

OR(TRUE, FALSE)

and returns TRUE.

#### Step 4 - Evaluate IF function

The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.

IF(*logical_test*, [*value_if_true*], [*value_if_false*])

IF(OR(C3>5,C3<1),B3,"")

## 9. OR function contains text

Formula in cell D3:

### 9.1 Explaining formula in cell C3

#### Step 1 - Search value for strings

The SEARCH function returns the position of the character at which a specific text string is found. Luckily the IF function accepts any number as TRUE except 0 (zero), however, the SEARCH function returns an error #VALUE! if it can't find the text string.

SEARCH($E$3:$E$4,B3)

becomes

SEARCH({"pen";"ap"},"Stapler")

and returns {#VALUE!; 3}.

#### Step 2 - Check if number

To avoid the error value I use the ISNUMBER function that returns TRUE if a number and FALSE if anything else, also formula errors.

ISNUMBER(SEARCH($E$3:$E$4,B3))

becomes

ISNUMBER({#VALUE!; 3})

and returns {FALSE; TRUE}

#### Step 3 - Evaluate OR function

OR(ISNUMBER(SEARCH($E$3:$E$4,B3)))

becomes

OR({FALSE; TRUE})

and returns TRUE.

#### Step 3 - Evaluate IF function

The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.

IF(*logical_test*, [*value_if_true*], [*value_if_false*])

IF(OR(ISNUMBER(SEARCH($E$3:$E$4,B3))),B3,"")

becomes

IF(TRUE,B3,"")

and returns "Stapler".

## 10. OR function Conditional Formatting

The image above shows Conditional Formatting highlgihting cells in ceolumn B if they match the conditions specified in column D.

Conditional formatting formula applied to cell range B3:B8:

### 10.1 Explaining conditional formatting formula

#### Step 1 - Define reference to conditions

This reference must stay unchanged or locked to D3:D4, use the dollar sign character to lock a reference for both column and row.

$D$3:$D$4

#### Step 2 - Compare values

The equal sign is a logical operator that lets you compare value to value or in this case value to values. It returns a boolean value TRUE or FALSE.

B3=$D$3:$D$4

becomes

"Stapler"={"Printer"; "Ruler"}

and returns {FALSE; FALSE}

#### Step 3 - Evaluate logical tests

OR(B3=$D$3:$D$4)

becomes

OR({FALSE; FALSE})

and returns FALSE.

### 10.2 How to apply Conditional formatting

How to apply Conditional Formatting

## 11. Get Excel *.xlsx file

### 'OR' function examples

The following 12 articles contain the OR function.

Introduction In this post I am creating a spreadsheet that will calculate stock portfolio performance. To do this I am […]

Question: I have a list that I keep adding rows to. How do i create a border that expands as […]

This article demonstrates how to apply Conditional Formatting formula to a cell range, it finds cells that are in close […]

This post demonstrates how to highlight records with the closest value to a criterion, you can also choose to highlight […]

Here is how to highlight every other row using conditional formatting. Conditional formatting formula: =ISEVEN(ROW())*OR($B3:$D3<>"") Alternative CF formula: =EVEN(ROW())=ROW() This […]

The filter feature in Excel won't allow you to do OR logic between columns, however, you can if you allow […]

The image above shows the performance across industry groups for different date ranges, conditional formatting makes the table much easier […]

This article demonstrates several ways to check if a cell contains any value based on a list. The first example […]

This article demonstrates formulas that check if a cell value is equal to any value in a given list. Table […]

This article shows examples of how to use the IF function with the OR function. Table of Contents IF with […]

The image above demonstrates conditional formatting highlighting hours outside work hours, those cells are filled with grey except weekends. Conditional formatting […]

This article demonstrates how to filter an Excel defined Table based on the selected cell in a calendar. The calendar […]

## Functions in this article

### Functions in 'Logical' category

The OR function function is one of many functions in the 'Logical' category.

## How to comment

How to add a formula to your comment<code>Insert your formula here.</code>

Convert less than and larger than signsUse html character entities instead of less than and larger than signs.

< becomes < and > becomes >

How to add VBA code to your comment[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

How to add a picture to your comment:Upload picture to postimage.org or imgur

Paste image link to your comment.

Contact OscarYou can contact me through this contact form