![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Location: Surprise, AZ
Posts: 11
|
I have a worksheet:
Column B is a value for year 2002 Column C is a value for year 2001 Column D is a percentage of increase or decrease between the two years. If both B & C are equal to zero I want zero in column D, otherwise I want the percent of increase or decrease versus year 2001. In no instance to I want a Divide by Zero error. thanks, [ This Message was edited by: hal1543 on 2002-05-02 06:54 ] |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try something with the following format:
=IF(A1=B1,0,B1/A1)
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
New Member
Join Date: May 2002
Location: Surprise, AZ
Posts: 11
|
Thanks Al,
I tried your formula, but if A is greater than zero and B is = zero, I'm getting that dredded Divide by Zero error. Hal |
|
|
|
|
|
#4 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Give this a whirl:
=IF(c1=0,0,b1/c1) _________________ Cheers, NateO [ This Message was edited by: NateO on 2002-05-02 10:57 ] |
|
|
|
|
|
#5 |
|
New Member
Join Date: May 2002
Posts: 11
|
how about
=if(or(b1=0,c1=0),0,b1/c1) this way, if either one is zero, you get a zero in return. |
|
|
|
|
|
#6 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Here's where we need to step back from Excel and remember our basic arithmetic. If B1 is zero and you divide this by a number greater than zero, the solution is always zero, no need to extend the if statement.
|
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Depending on what you divide by what, I'd use Nate's suggestion (a bit shortened):
=IF(C1,B1/C1,0) or =IF(B1,C1/B1,0) Aladin |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|