View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Meltad Meltad is offline
external usenet poster
 
Posts: 98
Default More than 16 nested IFs!!!!

Hi Harlan,
You're right, I think I've got the order wrong...
I need to do the calculation using firstly P or then Q if P=0.
And to use the first value from right to left in the cells BB, AY, AS, AP,
AJ, AG, AA, X to do the rest of the calculation. Here are the corrected IFs
(I think!!)...

=
IF(AND($P20,$BB20),((($BB2-$P2))/BB2),
IF(AND($P2=0,$BB20),((($BB2-$Q2))/$BB2),
IF(AND($P20,$AY20),((($AY2-$P2))/$AY2),
IF(AND($P2=0,$AY20),((($AY2-$Q2))/$AY2),
IF(AND($P20,$AS20),((($AS2-$P2))/$AS2),
IF(AND($P2=0,$AS20),((($AS2-$Q2))/$AS2),
IF(AND($P20,$AP20),((($AP2-$P2))/$AP2),
IF(AND($P2=0,$AP20),((($AP2-$Q2))/$AP2),
IF(AND($P20,$AJ20),((($AJ2-$P2))/$AJ2),
IF(AND($P2=0,$AJ20),((($AJ2-$Q2))/$AJ2),
IF(AND($P20,$AG20),((($AG2-$P2))/$AG2),
IF(AND($P2=0,$AG20),((($AG2-$Q2))/$AG2),
IF(AND($P20,$AA20),((($AA2-$P2))/$AA2),
IF(AND($P2=0,$AA20),((($AA2-$Q2))/$AA2),
IF(AND($P20,$X20),((($X2-$P2))/$X2),
IF(AND($P2=0,$X20),((($X2-$Q2))/$X2),0))))))))))))))))



"Harlan Grove" wrote:

Meltad wrote...
....
EG If X20 and AA20, AG2=0 and AJ20, lowest margin is displayed as value
in AA2 but should be AJ2

....

My formula would use AA2 in this case because *YOUR* original formula
would use AA2 in this case. That is, *YOUR* original formula begins

=IF(AND($P20,$AA20),
((($AA2-$P2))/$AA2),
IF(AND($P2=0,$AA20),
((($AA2-$Q2))/$AA2),

If AA20, your original formula wouldn't check whether any other value
in cells X2, AG2, AJ2, AP2, AS2, AY5, BB2 is greater than zero or not.
If that's not what you intended, then your original formula was wrong,
and you need to provide corrected specs.