ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Want to calculate a percentage by dividing one cell by the other, (https://www.excelbanter.com/excel-discussion-misc-queries/36457-want-calculate-percentage-dividing-one-cell-other.html)

KMHarpe

Want to calculate a percentage by dividing one cell by the other,
 
I want to calculate a percentage, but don't want it to calculate if the cells
have a zero OR Negative numbers. How do I do this?


Nick Hodge

=if(A1<=0,0,A1/B1)

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"KMHarpe" wrote in message
...
I want to calculate a percentage, but don't want it to calculate if the
cells
have a zero OR Negative numbers. How do I do this?




[email protected]



Nick Hodge wrote:
"KMHarpe" wrote:
I want to calculate a percentage, but don't want it to
calculate if the cells have a zero OR Negative numbers.
How do I do this?


=if(A1<=0,0,A1/B1)


More precisely (because the OP said "cells"):

=if(or(A1<=0,B1<=0), 0, A1/B1)

and format the cell appropriately.

But the OP was unclear about what to do when the "cells"
are zero or negative. Nick's solution puts a zero into
the "percentage" cell. If you want the cell to remain
empty, simply do:

=if(or(A1<=0,B1<=0), "", A1/B1)



All times are GMT +1. The time now is 11:57 AM.

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