Excel OR Function

The Excel OR function performs a test on two or more conditions and returns a TRUE result if one of the conditions was met or a FALSE result if all of the specified conditions were not met

Example: Excel OR Function

Excel OR Function

METHOD 1. Excel OR Function using hardcoded values

EXCEL

=OR(B8="win",B8="loss")
Result in cell C8 (TRUE) - returns a TRUE value give that one of the conditions was met.

=OR(B9="win",B9="loss")
Result in cell C9 (FALSE) - returns a FALSE value give all of the conditions were not met.

=OR(B10="win",B10="loss")
Result in cell C10 (TRUE) - returns a TRUE value give that one of the conditions was met.

METHOD 2. Excel OR Function using links

EXCEL

=OR(B8=$B$5,B8=$C$5)
Result in cell C8 (TRUE) - returns a TRUE value give that one of the conditions was met.

=OR(B9=$B$5,B9=$C$5)
Result in cell C9 (FALSE) - returns a FALSE value give all of the conditions were not met.

=OR(B10=$B$5,B10=$C$5)
Result in cell C10 (TRUE) - returns a TRUE value give that one of the conditions was met.

METHOD 3. Excel OR function using the Excel built-in function library with hardcoded values

EXCEL

Formulas tab > Function Library group > Logical > OR > populate the input boxes

=OR(B8="win",B8="loss")
Note: in this example we are populating the OR function input boxes with two conditions. One of these conditions was met and therefore the OR function returns a TRUE value.
Built-in Excel OR Function using hardcoded values

METHOD 4. Excel OR function using the Excel built-in function library with links

EXCEL

Formulas tab > Function Library group > Logical > OR > populate the input boxes

=OR(B8=$B$5,B8=$C$5)
Note: in this example we are populating the OR function input boxes with two conditions. One of these conditions was met and therefore the OR function returns a TRUE value.
Built-in Excel OR Function using links

METHOD 1. Excel OR function using VBA with hardcoded values

VBA

Sub Excel_OR_Function_Using_Hardcoded_Values()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("OR")
'apply the Excel OR function

ws.Range("C8") = ws.Range("B8") = "win" Or ws.Range("B8") = "loss"
ws.Range("C9") = ws.Range("B9") = "win" Or ws.Range("B9") = "loss"
ws.Range("C10") = ws.Range("B10") = "win" Or ws.Range("B10") = "loss"

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named OR.

ADJUSTABLE PARAMETERS
Output Ranges: Select the output ranges by changing the cell references ("C8"), ("C9") and ("C10") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.

METHOD 2. Excel OR function using VBA with links

VBA

Sub Excel_OR_Function_Using_Links()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("OR")
'apply the Excel OR function

ws.Range("C8") = ws.Range("B8") = ws.Range("$B$5") Or ws.Range("B8") = ws.Range("$C$5")
ws.Range("C9") = ws.Range("B9") = ws.Range("$B$5") Or ws.Range("B9") = ws.Range("$C$5")
ws.Range("C10") = ws.Range("B10") = ws.Range("$B$5") Or ws.Range("B10") = ws.Range("$C$5")

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named OR.

ADJUSTABLE PARAMETERS
Output Ranges: Select the output ranges by changing the cell references ("C8"), ("C9") and ("C10") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.

METHOD 3. Excel OR function with a For Loop using VBA

VBA

Sub Excel_OR_Function_Using_Links()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("OR")
'apply the Excel OR function

For x = 8 To 10
On Error Resume Next
ws.Cells(x, 3) = ws.Cells(x, 2) = ws.Range("$B$5") Or ws.Cells(x, 2) = ws.Range("$C$5")
Next

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.

PREREQUISITES
Worksheet Name: Have a worksheet named OR.

Usage of the Excel OR function and formula syntax

EXPLANATION

DESCRIPTION
The Excel OR function performs a test on two or more conditions and returns a TRUE result if one of the conditions is met or a FALSE result if all of the specified conditions were not met.
SYNTAX
=OR(logical1, [logical2], ...)
ARGUMENTS
logical1: (Required) A condition that you want to test.
logical2: (Optional) A condition that you want to test.

ADDITIONAL NOTES
Note 1: In Excel 2007 and later the OR function can accept up to 255 logical arguments. In Excel 2003 the OR function can only accept up to 30 logical arguments.
Note 2: The OR function ignores empty cells.