ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   multiple IF statements (https://www.excelbanter.com/excel-worksheet-functions/152003-multiple-if-statements.html)

tom

multiple IF statements
 
Hi gang,
my head is spinning around...what would be the best way to write this one?
In cell D20:

IF J9<7,D20=J9
IF J9=7,D20=0
IF J97<14,D20=J9-D21
IF J9=14, D20=0
IF J914<28,D20=J9-D21
IF J9=28, D20=0
IF J928<42,D20=J9-D21
IF J9=42, D20=0
IF J942<56, D20=J9-D21

thanks in advance!


Duke Carey

multiple IF statements
 
=if(j9={7,14,28,42},0,j9-d21*(j97))

Doesn't deal with the case that J9 = 56

If =56, use

=IF(J9={7,14,28,42},0,J9-D21*(J97))*(J9<56)

"Tom" wrote:

Hi gang,
my head is spinning around...what would be the best way to write this one?
In cell D20:

IF J9<7,D20=J9
IF J9=7,D20=0
IF J97<14,D20=J9-D21
IF J9=14, D20=0
IF J914<28,D20=J9-D21
IF J9=28, D20=0
IF J928<42,D20=J9-D21
IF J9=42, D20=0
IF J942<56, D20=J9-D21

thanks in advance!


Don Guillett

multiple IF statements
 
try this idea. Notice I did the 0's first and worked from the top down.
=J9-IF(OR(J955,J9=42,J9=28,J9=14,J9=7),0,IF(OR(J942, J928,J914,J97),D21))
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
Hi gang,
my head is spinning around...what would be the best way to write this one?
In cell D20:

IF J9<7,D20=J9
IF J9=7,D20=0
IF J97<14,D20=J9-D21
IF J9=14, D20=0
IF J914<28,D20=J9-D21
IF J9=28, D20=0
IF J928<42,D20=J9-D21
IF J9=42, D20=0
IF J942<56, D20=J9-D21

thanks in advance!



Duke Carey

multiple IF statements
 
Left out a portion

=IF(OR(J9={7,14,28,42}),0,J9-D21*(J97))
which ignores what happens if J9 56

If it should return 0 when 56 then

=IF(OR(J9={7,14,28,42}),0,J9-D21*(J97))*(J9<56)

"Duke Carey" wrote:

=if(j9={7,14,28,42},0,j9-d21*(j97))

Doesn't deal with the case that J9 = 56

If =56, use

=IF(J9={7,14,28,42},0,J9-D21*(J97))*(J9<56)

"Tom" wrote:

Hi gang,
my head is spinning around...what would be the best way to write this one?
In cell D20:

IF J9<7,D20=J9
IF J9=7,D20=0
IF J97<14,D20=J9-D21
IF J9=14, D20=0
IF J914<28,D20=J9-D21
IF J9=28, D20=0
IF J928<42,D20=J9-D21
IF J9=42, D20=0
IF J942<56, D20=J9-D21

thanks in advance!


Don Guillett

multiple IF statements
 
Duke's is best but mine could be used by subtracting j9
=J9-IF(OR(J955,J9=42,J9=28,J9=14,J9=7),j9,IF(OR(J942 ,J928,J914,J97),D21))


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
try this idea. Notice I did the 0's first and worked from the top down.
=J9-IF(OR(J955,J9=42,J9=28,J9=14,J9=7),0,IF(OR(J942, J928,J914,J97),D21))
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
Hi gang,
my head is spinning around...what would be the best way to write this
one?
In cell D20:

IF J9<7,D20=J9
IF J9=7,D20=0
IF J97<14,D20=J9-D21
IF J9=14, D20=0
IF J914<28,D20=J9-D21
IF J9=28, D20=0
IF J928<42,D20=J9-D21
IF J9=42, D20=0
IF J942<56, D20=J9-D21

thanks in advance!




joeu2004

multiple IF statements
 
On Jul 27, 7:46 am, Tom wrote:
what would be the best way to write this one? In cell D20:
IF J9<7,D20=J9
IF J9=7,D20=0
IF J97<14,D20=J9-D21
IF J9=14, D20=0
IF J914<28,D20=J9-D21
IF J9=28, D20=0
IF J928<42,D20=J9-D21
IF J9=42, D20=0
IF J942<56, D20=J9-D21


"Best" way? That's debatable. One way is:

=if(J9<7, 0, (mod(J9,7)<0)*(J9-D21))

Or perhaps the following would be more clear to you:

=if(or(J9<7, mod(J9,7)=0), 0, J9-D21)

Note that this ass-u-me-s that you want 0 for all multiples of 7,
including 56 and beyond, and that you want J9-D21 for non-multiples of
7, including 57 and beyond.


joeu2004

multiple IF statements
 
Errata....

On Jul 27, 9:01 am, I wrote:
On Jul 27, 7:46 am, Tom wrote:
what would be the best way to write this one? In cell D20:
IF J9<7,D20=J9
IF J9=7,D20=0
IF J97<14,D20=J9-D21


=if(J9<7, 0, (mod(J9,7)<0)*(J9-D21))


Oops, misread the conditions in an attempt to simplify. That should
be:

=if(J9<7, J9, (mod(J9,7)<0)*(J9-D21))

Or perhaps the following would be more clear to you:
=if(or(J9<7, mod(J9,7)=0), 0, J9-D21)


That should be:

=if(J9<7, J9, if(mod(J9,7)=0, 0, J9-D1))


Rick Rothstein \(MVP - VB\)

multiple IF statements
 
This should work...

=IF(MOD(J9,7)=0,0,J9-IF(J9<=7,0,D21))

Rick


"Tom" wrote in message
...
Hi gang,
my head is spinning around...what would be the best way to write this one?
In cell D20:

IF J9<7,D20=J9
IF J9=7,D20=0
IF J97<14,D20=J9-D21
IF J9=14, D20=0
IF J914<28,D20=J9-D21
IF J9=28, D20=0
IF J928<42,D20=J9-D21
IF J9=42, D20=0
IF J942<56, D20=J9-D21

thanks in advance!



Rick Rothstein \(MVP - VB\)

multiple IF statements
 
This should work...

=IF(MOD(J9,7)=0,0,J9-IF(J9<=7,0,D21))


Or a little more compactly, this...

=IF(MOD(J9,7)=0,0,J9-D21*(J97))

Rick

joeu2004

multiple IF statements
 
On Jul 27, 10:44 am, "Rick Rothstein \(MVP - VB\)"
wrote:
This should work...
=IF(MOD(J9,7)=0,0,J9-IF(J9<=7,0,D21))


I believe that returns 0 when J9=0, but the OP wants J9 when J9<7.

Therefore, I believe we must test J9<7 first. Note that this also
returns J9 when J9<0, which may or may not be want the OP intends, if
the OP even cares. But it does follow the OP's specifications.


Duke Carey

multiple IF statements
 
Rick & Joe -

The OP's specs omit 21 and 35 as conditions where he wants a zero result,
so your solutions incorporating MOD() will be erroneous

"Rick Rothstein (MVP - VB)" wrote:

This should work...

=IF(MOD(J9,7)=0,0,J9-IF(J9<=7,0,D21))

Rick


"Tom" wrote in message
...
Hi gang,
my head is spinning around...what would be the best way to write this one?
In cell D20:

IF J9<7,D20=J9
IF J9=7,D20=0
IF J97<14,D20=J9-D21
IF J9=14, D20=0
IF J914<28,D20=J9-D21
IF J9=28, D20=0
IF J928<42,D20=J9-D21
IF J9=42, D20=0
IF J942<56, D20=J9-D21

thanks in advance!




joeu2004

multiple IF statements
 
On Jul 27, 11:06 am, Duke Carey
wrote:
Rick & Joe -

The OP's specs omit 21 and 35 as conditions where he
wants a zero result, so your solutions incorporating MOD()
will be erroneous


Good eye!


Rick Rothstein \(MVP - VB\)

multiple IF statements
 
The OP's specs omit 21 and 35 as conditions where he
wants a zero result, so your solutions incorporating MOD()
will be erroneous


Good eye!


Yes indeed... I completely missed that!

Rick

Rick Rothstein \(MVP - VB\)

multiple IF statements
 
This should work...
=IF(MOD(J9,7)=0,0,J9-IF(J9<=7,0,D21))


I believe that returns 0 when J9=0, but the OP wants J9 when J9<7.


The formula is wrong for the reasons Duke pointed out, but as to your
statement... perhaps I am missing something in your statement, but isn't my
formula returning 0 when J9 equals zero the same thing as returning J9 when
J9 equals 0?

Rick


Rick Rothstein \(MVP - VB\)

multiple IF statements
 
Nice catch!!! I think this formula will account for all of the conditions...

D20: =IF(MOD(J9,14-7*(J9=7))<0,J9-IF(J9<=7,0,D21),0)

or, in slightly shorter form, this one...

D20: =(MOD(J9,14-7*(J9=7))<0)*(J9-D21*(J9=7))

While the formula produces values for J9<0 and J9=56, we are not in a
position to know what the OP wanted to happen there as he left his
intentions unstated.

Rick


"Duke Carey" wrote in message
...
Rick & Joe -

The OP's specs omit 21 and 35 as conditions where he wants a zero result,
so your solutions incorporating MOD() will be erroneous

"Rick Rothstein (MVP - VB)" wrote:

This should work...

=IF(MOD(J9,7)=0,0,J9-IF(J9<=7,0,D21))

Rick


"Tom" wrote in message
...
Hi gang,
my head is spinning around...what would be the best way to write this
one?
In cell D20:

IF J9<7,D20=J9
IF J9=7,D20=0
IF J97<14,D20=J9-D21
IF J9=14, D20=0
IF J914<28,D20=J9-D21
IF J9=28, D20=0
IF J928<42,D20=J9-D21
IF J9=42, D20=0
IF J942<56, D20=J9-D21

thanks in advance!






All times are GMT +1. The time now is 02:47 AM.

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