View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default HELP!!! Trouble with IF, AND functions

via135" wrote:
=IF(AND(B1<A1,A10),B1,IF(A1<0,0,A1))


"Ally1977" wrote apparently in response:
Your suggestion worked perfectly.


I am surprised to hear you say that. In "via135's" solution,
if B is negative and A is positive, the result will be negative
-- B.

But you wrote: "if the answer is going to be a negative I
want column C to say 0 not a negative number". I assume
that should be true even if B is negative, although you only
have an example with A negative.

Perhaps you never expect B<0. But the solution offered by
"arvi" still seems to be the best one, just in case, namely:

=max(0, min(a1,b1))

That is, choose the smaller of A or B, but choose 0 if the
smaller is negative. If you prefer an IF() function, then:

=if(or(A1<0,B1<0), 0, if(A1<B1, A1, B1))