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
=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
=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. |
METHOD 4. Excel OR function using the Excel built-in function library with links
EXCEL
=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. |
Dim ws As Worksheet
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
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.
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
Dim ws As Worksheet
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
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.
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
Dim ws As Worksheet
ws.Cells(x, 3) = ws.Cells(x, 2) = ws.Range("$B$5") Or ws.Cells(x, 2) = ws.Range("$C$5")
End Sub
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.
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.
=OR(logical1, [logical2], ...)
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.