Can someone Decipher this Excell Formula for me ???

  • Thread starter Thread starter Andy Yeo
  • Start date Start date
A

Andy Yeo

IF(C19<=G2,I2,IF(C19<=G4,(C19-G2)*H3+I2,IF(C19<=G6,(C19-G4)
*H5+I4,IF(C19<=G8,(C19-G6)*H7+I6,IF(C19<=G10,(C19-G8)
*H9+I8,IF(C19<=G12,(C19-G10)*H11+I10,IF(C19<=G14,(C19-G12)
*H13+I12,IF(C19<=G16,(C19-G14)*H15+I14,(C19-G16)
*H17+I16))))))))


if possible can you please convert it to C for me ?

Thanks
 
Andy Yeo said:
IF(C19<=G2,I2,IF(C19<=G4,(C19-G2)*H3+I2,IF(C19<=G6,(C19-G4)
*H5+I4,IF(C19<=G8,(C19-G6)*H7+I6,IF(C19<=G10,(C19-G8)
*H9+I8,IF(C19<=G12,(C19-G10)*H11+I10,IF(C19<=G14,(C19-G12)
*H13+I12,IF(C19<=G16,(C19-G14)*H15+I14,(C19-G16)
*H17+I16))))))))

This is a simple cell reference formula which can only be understood by
looking at the worksheet from which it came.
From what I see right off hand, there are 8 test's that this formula is told
to perform in sequence;
Test 1 is: IF(C19<=G2,I2
IF the content in cell C19 is less than or equal to the content in cell G2,
then post the content of cell I2 here (in the cell where you got this
formula), otherwise, perform the next test and so on.
Without looking at the entire sheet, it is highly unlikely you will be able
to figure out what the worksheet or formula is written for because it
performs several mathematical equations which can be used for just about
anything.
 
IF(C19<=G2,I2,IF(C19<=G4,(C19-G2)*H3+I2,IF(C19<=G6,(C19-G4)
*H5+I4,IF(C19<=G8,(C19-G6)*H7+I6,IF(C19<=G10,(C19-G8)
*H9+I8,IF(C19<=G12,(C19-G10)*H11+I10,IF(C19<=G14,(C19-G12)
*H13+I12,IF(C19<=G16,(C19-G14)*H15+I14,(C19-G16)
*H17+I16))))))))


if possible can you please convert it to C for me ?

/* should be something like this--*/
/* declare all variable as double */
double result;

if (C19<=G2) {
result = I2;
} else if (C19<=G4) {
result = (C19-G2)*H3+I2;
} else if (C19<=G6;
result = (C19-G4)*H5+I4;
} else if (C19<=G8) {
result = (C19-G6)*H7+I6;
} else if (C19<=G10) {
result = (C19-G8)*H9+I8;
} else if (C19<=G12) {
result = (C19-G10)*H11+I10;
} else if (C19<=G14) {
result = (C19-G12)*H13+I12
} else if (C19<=G16) {
result = (C19-G14)*H15+I14;
} else {
result = (C19-G16)*H17+I16;
}
 
On looking at it, my solution isn't right but you get the idea. Note that
Excel only allow 7 nested if's.

Mark
 
Back
Top