Monday, November 3, 2008

OR

I am going to try and keep this short and simple and to the point. If you knew me at all, you'd know that's a challenge, but I'm really going to try!

OR is a function like AND and ISERROR in that it returns a TRUE or FALSE result. So, like AND and ISERROR, OR is pretty worthless unless you couple it with an IF. It's like a Peanut Butter and Jelly sandwich without the bread.

If you create a formula like this:
=OR(B2="A",C2<=D2)
You will either get a TRUE or a FALSE result.

If that result is TRUE, you can use an IF statement to have it return a specific value, a result of a formula, or the value in a nearby cell. Or, 60 other things you might come up with. Here's an example where if at least one argument in my OR statement is TRUE, the formula returns the value found in H2. Otherwise, it returns a value of blank.

IF(OR(B2="A",C2<=D2),H2,"")

Regarding syntax, please note that your arguments in the OR statement are simply separated by commas. I often try to sneak one of these () in there, but that's just silly. Commas only. (The same is true for AND).

Finally, your OR statement is limited to only 30 arguments. Just 30. 31 is 1 too many, OK? (The same is true for AND).

Just in case I didn't make it clear enough, and because I think I've made my posts on AND and ISERROR too long and complex: OR, AND, ISERROR are all similar in that they all return TRUE or FALSE results and don't make much sense if you don't use them in conjunction with IF.

1 comment:

Chaitanya Sagar, Excel Expert said...

Just wanted to note that Excel 2007 accepts up to 255 conditions (both OR and AND).

Both AND and OR are beautiful. OR can check up to 255 conditions and if any one of them is true, can return TRUE.

How do we return TRUE if at least x number of the conditions are true or not more than X number of conditions are true?