View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove
 
Posts: n/a
Default Can't add 7th IF statement to long formula.

manxman wrote...
Here is the whole formula:


[reformatted]
=IF(AND(($X2+$Y2)
=MAX(($X2+$Y2),($AF2+$AG2),($AN2+$AO2),($AT2+$AU2) ,($AZ2+$BA2),($BF2+$BG2)),
($X2+$Y2)=BQ$2),$V6,
IF(AND(($AF2+$AG2)
=MAX(($X2+$Y2),($AF2+$AG2),($AN2+$AO2),($AT2+$AU2) ,($AZ2+$BA2),($BF2+$BG2)),
($AF2+$AG2)=BQ$2),$AD6,
IF(AND(($AN2+$AO2)
=MAX(($X2+$Y2),($AF2+$AG2),($AN2+$AO2),($AT2+$AU2) ,($AZ2+$BA2),($BF2+$BG2)),
($AN2+$AO2)=BQ$2),$AL6,
IF(AND(($AT2+$AU2)
=MAX(($X2+$Y2),($AF2+$AG2),($AN2+$AO2),($AT2+$AU2) ,($AZ2+$BA2),($BF2+$BG2)),
($AT2+$AU2)=BQ$2),$AR6,
IF(AND(($AZ2+$BA2)
=MAX(($X2+$Y2),($AF2+$AG2),($AN2+$AO2),($AT2+$AU2) ,($AZ2+$BA2),($BF2+$BG2)),
($AZ2+$BA2)=BQ$2),$AX6,
IF(AND(($BF2+$BG2)
=MAX(($X2+$Y2),($AF2+$AG2),($AN2+$AO2),($AT2+$AU2) ,($AZ2+$BA2),($BF2+$BG2)),
($BF2+$BG2)=BQ$2),$BD6,
"--"))))))

OK, so I did guess what you were trying to do: find the maximum sum of
pairs of cells in nonadjacent ranges and return a corresponding value
but also check that these cells sum to something greater than some
other cell.

Your ranges are uniformly spaced, every 6 columns, so take advantage of
that.

Try the array formula

=IF(MAX(IF(MOD(COLUMN($V6:$BD6)-COLUMN($V6),6)=0,$X2:$BF2+$Y2:$BG2))=
BQ$2,INDEX($V6:$BD6,MATCH(MAX($X2+$Y2,$AF2+$AG2,$A N2+$AO2,
$AT2+$AU2,$AZ2+$BA2,$BF2+$BG2),IF(MOD(COLUMN($V6:$ BD6)-COLUMN($V6),6)
=0,$X2:$BF2+$Y2:$BG2),0)),"--")