Help With If Function

  • Thread starter Thread starter Wendy L
  • Start date Start date
W

Wendy L

When you are using an "IF" function, I know you can use an "and" comparison
by using an asterisk between your comparisons, for example:

=IF((A1=1)*(B1=1),"S","")

What I want to know is this: Is there anyway to do an "or" comparison? So my
formula would be:

=IF((A1=1)OR(B1=1),"S","")

Now, obviously I know I can't just stick the word "OR" in there but is there
a way to do this?
 
Wendy,

Getting confused here

=IF(AND(A1=1,B1=1),"S","")

is And, the Or is

=IF(OR(A1=1,B1=1),"S","")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Thank you so much, this worked like a charm.

Perhaps I learned it wrong, but the asterisk between the parenthesis DOES
work as an "AND" comparison. Try it!
 
You're right; your formula does work. To make it do an
or, you can replace the "*" with a "+". Using AND/OR is
generally seen as the "best" way to do this, but using
the boolean results works, too. Of course, if MS ever
decides that TRUE=0 and FALSE=1, you may get interesting
results!
 
Wendy,

I think Bob's answer is better, but if you want to use the same kind of
syntax you use by * for AND, you could use + for OR.
=IF((A1=1)+(B1=1),"S","") will give you S if A1=1 or B1=1 (or if they are
both equal to 1).


--
Regards,
Auk Ales

* Please reply to this newsgroup only *
* I will not react on unsolicited e-mails *
 
Beth,

Yes it does because each test evaluates to true or false, and multiplying
two such evaluations together produces 1 or 0, which can be tested in a
boolean expression (i.e. the IF) - confusing eh? In example, we get

(A1=1) * (B1=1) Result
True True 1 - succeeds
True False 0 - fails
False True 0 - fails
False False 0 - fails


It can be done, and the Or is done with

=IF((A1=1)+(B1=1),"S","")

but * for AND and + for OR is not exactly intuitive when you have the AND
and OR functions is it?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top