# #DIV/0! error when cells are blank

#### RutlandPuritan

##### New Member
Hello.

I have a timetable on Excel. The first worksheet is organized into blocks of different activities.

For each activity there are staff members and participants listed.

On the second worksheet, I use formulae like this one:

=((COUNTIF(Mon!\$B\$9:\$B\$14,A4)*\$B\$2)/COUNTIF(Mon!\$B\$5:\$B\$7,"*")/COUNTIF(Mon!\$B\$9:\$B\$14,"*"))

So if, for example, Fred's name is in A4, it will give the number of hours as defined in B2. It will then divide this by the number of staff and the number of participants (i.e. if any text is the specified range) to give the total support hours.

This works fine except if (in this instance) B9:B14 and B5:B7 are blank. It then produces a #DIV/0! error.

This is a problem because the cell adds up for all of the activity blocks and looks like this:

=((COUNTIF(Mon!\$B\$9:\$B\$14,A4)*\$B\$2)/COUNTIF(Mon!\$B\$5:\$B\$7,"*")/COUNTIF(Mon!\$B\$9:\$B\$14,"*"))
+((COUNTIF(Mon!\$B\$19:\$B\$24,A4)*\$B\$2)/COUNTIF(Mon!\$B\$17,"*")/COUNTIF(Mon!\$B\$19:\$B\$24,"*"))
+((COUNTIF(Mon!\$B\$30:\$B\$36,A4)*\$B\$2)/COUNTIF(Mon!\$B\$27:\$B\$28,"*")/COUNTIF(Mon!\$B\$30:\$B\$36,"*"))
+((COUNTIF(Mon!\$B\$42:\$B\$47,A4)*\$B\$2)/COUNTIF(Mon!\$B\$39:\$B\$40,"*")/COUNTIF(Mon!\$B\$42:\$B\$47,"*"))
+((COUNTIF(Mon!\$B\$42:\$B\$47,A4)*\$B\$2)/COUNTIF(Mon!\$B\$39:\$B\$40,"*")/COUNTIF(Mon!\$B\$42:\$B\$47,"*"))...

Sometimes certain activity blocks will be empty and others, which were empty, filled in. I want this formula to give me the results without having to change it all the time.

So what I would like Excel to do is ignore one range of cells if it is blank, but still continue to add up the others which are not blank.

Is this achievable?

### Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

#### Scott T

##### Well-known Member
You can use IFERROR on each formula to return zero if there is an error.
Code:
``````=IFERROR((COUNTIF(Mon!\$B\$9:\$B\$14,A4)*\$B\$2)/COUNTIF(Mon!\$B\$5:\$B\$7,"*")/COUNTIF(Mon!\$B\$9:\$B\$14,"*"),0)
+IFERROR((COUNTIF(Mon!\$B\$19:\$B\$24,A4)*\$B\$2)/COUNTIF(Mon!\$B\$17,"*")/COUNTIF(Mon!\$B\$19:\$B\$24,"*"),0)
+IFERROR((COUNTIF(Mon!\$B\$30:\$B\$36,A4)*\$B\$2)/COUNTIF(Mon!\$B\$27:\$B\$28,"*")/COUNTIF(Mon!\$B\$30:\$B\$36,"*"),0)
+IFERROR((COUNTIF(Mon!\$B\$42:\$B\$47,A4)*\$B\$2)/COUNTIF(Mon!\$B\$39:\$B\$40,"*")/COUNTIF(Mon!\$B\$42:\$B\$47,"*"),0)``````

Replies
3
Views
48
Replies
0
Views
44
Replies
3
Views
98
Replies
5
Views
129
Replies
7
Views
135

1,128,018
Messages
5,628,167
Members
416,297
Latest member
Kara Payne

### 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?

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