Logical Expressions

Location: http:www.mvps.org/dmcritchie/excel/logical.htm  
Home page: http:www.mvps.org/dmcritchie/excel/excel.htm
[View without Frames]

AND and OR

AND and OR are logical functions and will return either a True or a False
    0 will be considered False, everything else as True.


11  --OR-- TRUE  =OR(C$1,C$2,C$3,C$4)
21  Opposite FALSE  =AND(NOT(C$1),NOT(C$2),NOT(C$3),NOT(C$4))
30  Same TRUE   =NOT(AND(NOT(C$1),NOT(C$2),NOT(C$3),NOT(C$4)))
5   --AND-- FALSE  =AND(C$1,C$2,C$3,C$4)
6   Opposite TRUE  =OR(NOT(C$1),NOT(C$2),NOT(C$3),NOT(C$4))
7   Same FALSE   =NOT(OR(NOT(C$1),NOT(C$2),NOT(C$3),NOT(C$4)))

with AND if all of the bits are True it will return True; otherwise, False
with OR if any of the bits are True it will return True; otherwise, False
with NOT whatever is True becomes False, whatever was False becomes True.

The opposite of   OR(c1,c2,...cn)
     is to change each condition to the opposite and change the OR to AND
     i.e. AND(NOT(c1),NOT(c2),..., NOT(cn))
Therefore the equivalent of  OR(c1,c2,...cn)   would be
          NOT(AND(NOT(c1),NOT(c2),..., NOT(cn)))

Additional Comments:

ISERR() is a condition and returns True or False, it is a negative of the content being valid

FALSE()  is a builtin function that returns False  so that you can type  FALSE into your worksheet.

VBA Coding

Coding in VBA differs quite a bit for NOT with no parens.

IF cond1 OR cond2 OR ... OR condn

would be equivalent to the ELSE of the following test:
  IF NOT (cond1 OR cond2 OR ... OR condn) THEN ...

but the difference shows up if there is only one condition -- no parens needed:
  IF NOT cond1 THEN ...


This page was introduced on August 29, 2002. 

[My Excel Pages -- home]    [INDEX to my site and the off-site pages I reference] 
[Site Search -- Excel]     [Go Back]    [Return to TOP

Please send your comments concerning this web page to: David McRitchie send email comments

Copyright © 1997 - 2004,  F. David McRitchie,  All Rights Reserved