Having a div/0 error in excel 2007 return a 0 with in a large formula
I apologize if this is not considered real programming since it is in Excel but I need help and this is the most helpful place I know!
Alright so I have a very large if formula in excel:
=IF(AND(($EZ16+LF$1139)>$B$1145,($EZ16+LF$1139)<$B$1146),IF(OR(AND($FB16<LF$1141,$FB16>LF$1142),AND($FE16<LF$1141,$FE16>LF$1142),AND($FH16<LF$1141,$FH16>LF$1142),AND($FK16<LF$1141,$FK16>LF$1142),AND($FN16<LF$1141,$FN16>LF$1142),AND($FQ16<LF$1141,$FQ16>LF$1142),AND($FT16<LF$1141,$FT16>LF$1142),AND($FW16<LF$1141,$FW16>LF$1142),AND($FZ16<LF$1141,$FZ16>LF$1142),AND($GC16<LF$1141,$GC16>LF$1142),AND($GF16<LF$1141,$GF16>LF$1142)),FALSE,(EU16/EI16-1)),FALSE)
What can I do to it so that if it returns a div/0 error it will pass a value of 0 instead of the #DIV/0!
error?
Would it be something like:
=IF(ISERROR(A1/B1),0,A1/B1)
If so how can I add that to my current formula and not break it? Would it be:
=IF(ISERROR(IF(AND(($EZ16+LF$1139)>$B$1145,($EZ16+LF$1139)<$B$1146),IF(OR(AND($FB16<LF$1141,$FB16>LF$1142),AND($FE16<LF$1141,$FE16>LF$1142),AND($FH16<LF$1141,$FH16>LF$1142),AND($FK16<LF$1141,$FK16>LF$1142),AND($FN16<LF$1141,$FN16>LF$1142),AND($FQ16<LF$1141,$FQ16>LF$1142),AND($FT16<LF$1141,$FT16>LF$1142),AND($FW16<LF$1141,$FW16>LF$1142),AND($FZ16<LF$1141,$FZ16>LF$1142),AND($GC16<LF$1141,$GC16>LF$1142),AND($GF16<LF$1141,$GF16>LF$1142)),FALSE,(EU16/EI16-1)),FALSE))**),0,IF**(AND(($EZ16+LF$1139)>$B$1145,($EZ16+LF$1139)<$B$1146),IF(OR(AND($FB16<LF$1141,$FB16>LF$1142),AND($FE16<LF$1141,$FE16>LF$1142),AND($FH16<LF$1141,$FH16>LF$1142),AND($FK16<LF$1141,$FK16>LF$1142),AND($FN16<LF$1141开发者_Python百科,$FN16>LF$1142),AND($FQ16<LF$1141,$FQ16>LF$1142),AND($FT16<LF$1141,$FT16>LF$1142),AND($FW16<LF$1141,$FW16>LF$1142),AND($FZ16<LF$1141,$FZ16>LF$1142),AND($GC16<LF$1141,$GC16>LF$1142),AND($GF16<LF$1141,$GF16>LF$1142)),FALSE,(EU16/EI16-1)),FALSE))
Thank you for the help!
EDIT: Tim a tried your suggestion:
=IF(AND(($EZ16+LF$1139)>$B$1145,($EZ16+LF$1139)<$B$1146),IF(OR(AND($FB16<LF$1141,$FB16>LF$1142),AND($FE16<LF$1141,$FE16>LF$1142),AND($FH16<LF$1141,$FH16>LF$1142),AND($FK16<LF$1141,$FK16>LF$1142),AND($FN16<LF$1141,$FN16>LF$1142),AND($FQ16<LF$1141,$FQ16>LF$1142),AND($FT16<LF$1141,$FT16>LF$1142),AND($FW16<LF$1141,$FW16>LF$1142),AND($FZ16<LF$1141,$FZ16>LF$1142),AND($GC16<LF$1141,$GC16>LF$1142),AND($GF16<LF$1141,$GF16>LF$1142)),FALSE,IF(EI16=1,0,EU16/EI16-1)),FALSE)
Still getting a #DIV/0
error, any idea why?
Excel 2007 has a new IFERROR function that you can use like
=IFERROR(MyLongFormula,0)
=IsError(100/0)
will return TRUE
, so make the conditional before to output 0, =IF(IsError(*),0,...)
I wouldn't recommend duplicating the whole formula like that: a complicated formula just got twice as complicated.
Since the division only happens in one place, I'd recommend putting the check there. This:
...(EU16/EI16-1)...
becomes this:
...IF(EI16=1, 0, EU16/EI16-1)...
精彩评论