ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   IF statements (https://www.excelbanter.com/excel-discussion-misc-queries/123259-if-statements.html)

profmorse

IF statements
 
how can I build an If statement that answers the following; If A+B<0 then
chose A only if A is greater than 0, otherwise chose B, only if B is greater
than zero, otherwise 0.

Bob Phillips

IF statements
 
=IF(A1+B1<0,IF(A10,A1,IF(B10,B1,0)),0)

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"profmorse" wrote in message
...
how can I build an If statement that answers the following; If A+B<0 then
chose A only if A is greater than 0, otherwise chose B, only if B is
greater
than zero, otherwise 0.




Brad

IF statements
 
Another solution
=if(a+b<0,max(a,0),max(b,0))

"profmorse" wrote:

how can I build an If statement that answers the following; If A+B<0 then
chose A only if A is greater than 0, otherwise chose B, only if B is greater
than zero, otherwise 0.


Sandy Mann

IF statements
 
Just another option,

=((A1+B1)<0)*MAX(A1,B1,0)
--
HTH

Sandy
Retired for Work
But hopefully not from Life


with @tiscali.co.uk


"profmorse" wrote in message
...
how can I build an If statement that answers the following; If A+B<0 then
chose A only if A is greater than 0, otherwise chose B, only if B is
greater
than zero, otherwise 0.




Brad

IF statements
 
Yes, that would work just as well - both a1 and b1 cannot be positive and
meet the first condition - and if both of them are negative you will still
get zero as an answer


"Sandy Mann" wrote:

Just another option,

=((A1+B1)<0)*MAX(A1,B1,0)
--
HTH

Sandy
Retired for Work
But hopefully not from Life


with @tiscali.co.uk


"profmorse" wrote in message
...
how can I build an If statement that answers the following; If A+B<0 then
chose A only if A is greater than 0, otherwise chose B, only if B is
greater
than zero, otherwise 0.





driller2

profmorse

=--IF(and(A1+B1<0,MAX(A1:B1)0),MAX(A1:B1))

happy holidays hohoho..:)
romelsb @ banter

Quote:

Originally Posted by Brad
Another solution
=if(a+b<0,max(a,0),max(b,0))

"profmorse" wrote:

how can I build an If statement that answers the following; If A+B<0 then
chose A only if A is greater than 0, otherwise chose B, only if B is greater
than zero, otherwise 0.



All times are GMT +1. The time now is 04:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com