I have 2 columns that span across many rows. What I need to do is calculate the percentage of each row and then add them. Setup is something like:

```
ColA ColB
5 5
10
10
3 7
```

The total for ColA, should be calculated like (5/(5+5))+(10/(5+5))+(0/(0+10))+(3/(3+7)). I have a formula which works in:

`=SUMPRODUCT((A2:A1000)/(A2:A1000+B2:B1000))`

The problem is that if there are blank values in both rows, then it gives the #DIV/0 error because you can’t divide by 0. How would I write the formula to exclude rows where both are blank?

**EDIT:**

Some actual data and expected values are:

```
ColA ColB
40
40
35
35
35
35
35
35
17.5 17.5
40
40
40
40
7.5 28.5
36
36
36
36
```

When totaling ColA, should be *9.7*

When totaling ColB, should be *8.3*

You can use an “array formula” like this:

`=SUM(IFERROR((A2:A1000)/(A2:A1000+B2:B1000),0))`

confirmed with `CTRL`+`SHIFT`+`ENTER`

That works in excel 2007 or later versions

see screenshot

Tags: excelexcel