Avoid div/0 error?

MsCynic

Board Regular
Joined
May 21, 2006
Messages
122
Hi guys, when dragging a cell down to repeat a formula throughout a column, what is the trick that avoids having the #DIV/0! error display on rows without data in them?

Thanks in advance,
C
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
There are many ways to do this. You could do this using an if statement similar to this.

=IF(COUNTIF(
#VALUE!
 
Upvote 0
Hi Brian, many thanks for replying.

I have two columns of financials but within those column, some rows are blank. Eg:

Jan 06 Jan 07
12000 12222
33099

77000
78900 89000

I am using =(D136-P136)/ABS(P136) to establish the percentage change between January 2006 and January 2007. Naturally if either column has rows without any figure I get the Div/X error, which messes up the spreadsheet.

Cheers
C
 
Upvote 0
Hi

You can use the ISERROR Function to test for an error:

=IF(ISERROR((D136-P136)/ABS(P136)),"",(D136-P136)/ABS(P136))

So if there is an error in the calculttion it will return nothing as per the "" or do the calculation if there is no error.

Hope this helps
 
Upvote 0
Hi Brian, many thanks for replying.

I have two columns of financials but within those column, some rows are blank. Eg:

Jan 06 Jan 07
12000 12222
33099

77000
78900 89000

I am using =(D136-P136)/ABS(P136) to establish the percentage change between January 2006 and January 2007. Naturally if either column has rows without any figure I get the Div/X error, which messes up the spreadsheet.

Cheers
C

=IF(COUNTBLANK(D136,P136),"",(D136-P136)/ABS(P136))
 
Upvote 0
Hi

You can use the ISERROR Function to test for an error:

=IF(ISERROR((D136-P136)/ABS(P136)),"",(D136-P136)/ABS(P136))

So if there is an error in the calculttion it will return nothing as per the "" or do the calculation if there is no error.

Hope this helps

You can even specify characters in between "" if you want to display a particular value when the calculation has an error :wink:
 
Upvote 0
Naturally if either column has rows without any figure I get the Div/X error, which messes up the spreadsheet.

Based on your formula, it's not either column that is causing the #DIV/0!, It's what you are dividing by that is causing it.

What is causing #DIV/0 in this case is P136 as this is the denominator in your formula

For just checking if you are actually dividing by 0 or not:

=IF(P136,(D136-P136)/ABS(P136),"")

which means if P136 has a non-zero value go ahead and do the division, otherwise return blank.

Aladin:
I don't believe you can use non-contiguous ranges with COUNTBLANK
 
Upvote 0
...
Aladin:
I don't believe you can use non-contiguous ranges with COUNTBLANK

I see a presupposition does necessarily hold... :LOL:

I thought the OP is after something like...

=IF((N(D136)=0)+(N(P136)=0),"",(D136-P136)/ABS(P136))
 
Upvote 0
I hesitate to try to add anything in this exaulted company, but here is what I sometimes use, which avoids the use of the "IF" function.

=((P136<>0)*(D136-P136))/ABS(((P136=0)+P136)). It returns a zero in the event that P136 is a zero.
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,666
Members
448,977
Latest member
moonlight6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top