ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do I get rid of the #/DIV/0! message (https://www.excelbanter.com/excel-worksheet-functions/38540-how-do-i-get-rid-div-0-message.html)

Marshall Scmidt

How do I get rid of the #/DIV/0! message
 
If I have a formula say (A2+A10)*A12/A15 if A15 is blank it returns
#/DIV/0!, how do i get it to return 0
--
Marshall

Hayeso

=IF(ISERR((A2+A10)*A12/A15),"",(A2+A10)*A12/A15)

"Marshall Scmidt" wrote:

If I have a formula say (A2+A10)*A12/A15 if A15 is blank it returns
#/DIV/0!, how do i get it to return 0
--
Marshall


Niek Otten

=IF(A15=0,0,(A2+A10)*A12/A15)

--
Kind regards,

Niek Otten

Microsoft MVP - Excel

"Marshall Scmidt" wrote in
message ...
If I have a formula say (A2+A10)*A12/A15 if A15 is blank it returns
#/DIV/0!, how do i get it to return 0
--
Marshall




Harlan Grove

Hayeso wrote...
=IF(ISERR((A2+A10)*A12/A15),"",(A2+A10)*A12/A15)

....

Errors are not always a bad thing to see. #REF!, #NULL!, #NUM! and
#NAME? are always beneficial diagnostically. #DIV/0! is always easy to
avoid in direct calculations (check if the denominator term is zero).
Only #VALUE! and #N/A require trapping on an all too frequent basis.

Next, ISERR as opposed to ISERROR won't trap #N/A. Maybe you intended
that, but why allow #N/A but not #REF!, #NULL!, #NUM! and #NAME?
results?

In general you should only trap expected errors or expected values that
would give rise to errors, such as blank denominator terms. In this
case, the formula should only trap cell A15 blank, not A15=0. So

=IF(ISBLANK(A15),0,(A2+A10)*A12/A15)

and if this were part of a larger formula, you could use only a single
level of function calls with

(A2+A10)*A12*(1-ISBLANK(A15))/(A15+ISBLANK(A15))

More generally, to trap only specific errors, use

=IF(COUNT(1/(ERROR.TYPE(x)={3,7})),"error result","nonerror result")

where 3 == #VALUE! and 7 == #N/A.



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

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