ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Dividing by Zero (https://www.excelbanter.com/excel-discussion-misc-queries/180332-dividing-zero.html)

TomRW

Dividing by Zero
 
If I have 8 in A1 and 2 in A2 I get 25%.

But if I have 8 in A1 and 0 in A2 I get #DIV/0!. When I want to get 0
or 0%.

Simple remedy?

Chip Pearson

Dividing by Zero
 
Use a formula like

=IF(A2=0,0,A1/A2)



"TomRW" wrote in message
...
If I have 8 in A1 and 2 in A2 I get 25%.

But if I have 8 in A1 and 0 in A2 I get #DIV/0!. When I want to get 0
or 0%.

Simple remedy?



George Nicholson

Dividing by Zero
 
=IF(A2 = 0, 0, A1/A2)

--
HTH,
George


"TomRW" wrote in message
...
If I have 8 in A1 and 2 in A2 I get 25%.

But if I have 8 in A1 and 0 in A2 I get #DIV/0!. When I want to get 0
or 0%.

Simple remedy?




David Biddulph[_2_]

Dividing by Zero
 
I'm intrigued as to what formula you are using that gives those results? If
you've got 8 in A1 and 2 in A2, then the most obvious formula to give 25%
would be =A2/A1, but if that is the formula you wouldn't get a #DIV/0! when
A2 is 0. If you are trying to protect against A1 (rather than A2) being
zero, then you could use =IF(A1=0,0,A2/A1), but be careful if you use that
formula, as you wouldn't see the difference in result between A1 being zero
and A2 being zero. As you reduce the value of A1, the result of the
division increases, but you have asked for it to reduce again when you get
to A1 being zero; the result of the division should be infinite, not zero,
so make sure that you don't confuse yourself.
--
David Biddulph

"TomRW" wrote in message
...
If I have 8 in A1 and 2 in A2 I get 25%.

But if I have 8 in A1 and 0 in A2 I get #DIV/0!. When I want to get 0
or 0%.

Simple remedy?





All times are GMT +1. The time now is 04:32 PM.

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