In Excel, the OR
function is a logical function that returns TRUE
if any of the conditions are true, and FALSE
if all conditions are false. Below are 10 examples of how to use the OR
function, including data and formulas.
Example 1: Basic OR Function
Data:
A1:
10
B1:
20
Formula:
=OR(A1 > 5, B1 < 15)
Result: TRUE
(because A1 > 5
is true).
Example 2: OR with Text Comparison
Data:
A1:
Apple
B1:
Banana
Formula:
=OR(A1 = "Apple", B1 = "Orange")
Result: TRUE
(because A1 = "Apple"
is true).
Example 3: OR with Multiple Conditions
Data:
A1:
50
B1:
75
C1:
100
Formula:
=OR(A1 > 60, B1 < 80, C1 = 100)
Result: TRUE
(because B1 < 80
and C1 = 100
are true).
Example 4: OR in an IF Statement
Data:
A1:
25
B1:
35
Formula:
=IF(OR(A1 > 20, B1 < 30), "Pass", "Fail")
Result: Pass
(because A1 > 20
is true).
Example 5: OR with AND Function
Data:
A1:
15
B1:
25
C1:
35
Formula:
=OR(AND(A1 > 10, B1 < 30), C1 = 40)
Result: TRUE
(because AND(A1 > 10, B1 < 30)
is true).
Example 6: OR with Cell References
Data:
A1:
TRUE
B1:
FALSE
C1:
TRUE
Formula:
=OR(A1, B1, C1)
Result: TRUE
(because A1
and C1
are true).
Example 7: OR with Dates
Data:
A1:
01/01/2023
B1:
02/01/2023
Formula:
=OR(A1 > DATE(2023, 1, 15), B1 < DATE(2023, 3, 1))
Result: TRUE
(because B1 < DATE(2023, 3, 1)
is true).
Example 8: OR with Blank Cells
Data:
A1:
100
B1: (Blank)
Formula:
=OR(A1 > 50, ISBLANK(B1))
Result: TRUE
(because both conditions are true).
Example 9: OR with Error Handling
Data:
A1:
10
B1:
#DIV/0!
Formula:
=OR(ISNUMBER(A1), ISERROR(B1))
Result: TRUE
(because ISNUMBER(A1)
and ISERROR(B1)
are true).
Example 10: OR in Conditional Formatting
Data:
A1:
75
B1:
85
Conditional Formatting Rule:
=OR(A1 > 70, B1 > 80)
Result: The cells will be formatted if either condition is true.
These examples demonstrate the versatility of the OR
function in Excel, whether used alone or combined with other functions like IF
, AND
, ISBLANK
, or ISERROR
. Let me know if you need further clarification!
No comments:
Post a Comment