AND and OR Functions

If you want to write a formula like this

=IF(A1>10 And A2<20,”In Range”,”Out of Range”)

then you are candidate for the AND() function. AND() and OR() have the same syntax, so I’ll use AND() for the example. The above formula seems like the natural way to write the IF test, but AND() works like every other function, that is, first the function name, then the arguments. The relevant portion of the above formula would look like this

AND(A1>10,A2<20)

AND() will return True if every argument evaluates True. If even one argument returns False, the whole function returns False.

OR() will return True if any of the arguments is True. Only if they’re all False, will the whole function return False.

Posted in Uncategorized

2 thoughts on “AND and OR Functions

  1. Handy tip: instead of e.g.

    OR(A1=4,A1=6,A1=9)

    use

    OR(A1={4,6,9})

    Jamie.

    –

  2. Jamie: Good one. I should do a post about literal arrays in formulas, but I’m not sure I understand them. When I find a good place for one, I use trial and error to see if it works in that situation.


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.