OR()

Syntax. OR(logical1,logical2,...)

Definition. This function returns the logical value TRUE if at least one of the arguments is true. The OR() function returns the logical value FALSE only if all arguments are false.

Arguments

  • logical1,logical2,... Up to 30 (and in Excel 2007 and Excel 2010 up to 255) logical values or conditions that can be evaluated to logical values (TRUE or FALSE)

Background. If you use arguments other than references and text, the OR() function returns the #VALUE! error. Except for the value of zero, all numbers are interpreted as TRUE. If an argument is omitted, as in

=OR(TRUE)

FALSE is returned.

Arguments from references or arrays should evaluate to logical values (TRUE or FALSE). There are exceptions: If at least one argument can be evaluated, other arguments containing text or containing references to empty cells are ignored. If arguments contain error values, the result is also an error.

Example. If you enter the word text in cells B22 and B23, OR(B22,B23) returns the #VALUE! error, but OR(B22,B23,FALSE) and OR(B22,B23,0) each return FALSE. If you replace FALSE with TRUE and zero with another number, the logical value TRUE is returned.

You get the same results if you enter the word text in cells B25 and B27 and enter a logical value or a number in cell B26. When you evaluate OR(B25:B27), the cells containing text are ignored.

The example for the NOT() function checked whether a day falls at the end of the quarter:

=(AND(MOD(MONTH(B16),3)=0,DAY(B16)>20))

or

=NOT(AND(MOD(MONTH(B16),3)=0,DAY(B16)>20))

With the calculation rules in mind, the formula directly preceding could also be entered as

=OR(NOT(MOD(MONTH(B16),3)=0),NOT(DAY(B16)>20))

or

=OR(MOD(MONTH(B19),3)>0,DAY(B19)<=20)

The AND() function was replaced by the OR() function. In Excel Help you can find the following statement:

You can use an OR array formula to check if an array contains a certain value. To enter an array formula press Ctrl+Shift+Enter.

To test this, enter 2 in cell B34, and enter 1, 2, and 3 in cells C34 through C36. In cell D34, enter

=OR(B34=C34:C36)

If you press the Ctrl+Shift+Enter key combination instead of the Enter key, the formula returns TRUE:

{=OR(B34=C34:C36)}

This checks whether any of the values in the range C34:C36 are the same as the value in cell B34. If you change the value in B34 to 4, the result is FALSE. Excel interprets the array formula as

=OR(B34=C34,B34=C35,B34=C36)

and the result is TRUE if one of the arguments returns TRUE—in other words, if the content in cell B34 is identical to one of the numbers in the C34:C36 column.

If you use the array formula instead of the standard formula, you do not need to enter the arguments individually and are not restricted to 30 (in Excel 2003) or 255 (in Excel 2007 and Excel 2010) comparisons. You can force the comparison of B34 with (almost) any number of values, because OR(B34=reference cells) is used with only one argument.

See Also

AND(), NOT()

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.224.226