View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
rub rub is offline
external usenet poster
 
Posts: 21
Default I am having trouble with the IF function and a compound condition

Thanks it works.


Dave Peterson wrote:
One way is to translate your requirements word for word:
=if(or(and(a100=369,b100="Gas"),and(a100=391,b100= "Gas")),54,18)

Another way that's equivalent Since B100 has to be Gas for both 369 and 391:
=if(and(b100="gas",or(a100=369,a100=391)),54,18)


And another way to write that formula that makes it easier if the number of
values in A100 can get bigger:

=if(and(b100="gas",or(a100={369,391})),54,18)



rub wrote:

I want to use the IF function to set a value of 54 if A100=369 and
B100="Gas" or A100=391 and B100="Gas". Otherwise the value should be
18.

I used =IF((A100=369 and B100="Gas") or (A100=391 and
B100="Gas"),54,18) and got an error.

I also used =IF(B100="Gas" and (A100=369 or A100=391), 54,18) and also
got an error.

Any ideas?


--

Dave Peterson