# Divide by zero error in cell range

Ian Bell used Ask the Experts™
on
Hi,

I would like a formula modified to avoid getting divide by zero errors. The formula was kindly provided by a member yesterday however
since using on a new spreadsheet containing zeros it throws up the errors.
Please refer to attached spreadsheet   The zero is highlighted Sum-Probabilities-to-one-V2.xlsxin cell B17
Many thanks
Ian
Comment
Watch Question

Do more with

EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
Hi Ian,

Try this Array Formula which requires confirmation with Ctrl+Shift+Enter instead of Enter alone.

In E2
``````=IFERROR(1/B2/ROUND(SUM((\$A\$2:\$A\$31=A2)*(\$B\$2:\$B\$31<>0)/IF(\$B\$2:\$B\$31=0,1,\$B\$2:\$B\$31)),2),0)
``````
retired

Commented:
Hi Neeraj,
I was wanting it to establish the probs and the sum of the range would add to 1.
You have corrected the divide by zero error but the formula needs adjusting.
Thanks
Ian
Sum-Probabilities-to-one.xlsx
Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
Hi Ian,

I am not sure if I am getting you here.
Please look at the attached. The new formula is placed in column G and sum is placed in column H. What is missing in there?
Sum-Probabilities-to-one.xlsx
retired

Commented:
Worked okay, not sure what I did earlier as output was 1 for each cell.
However this formula is not practical for the 160,000 rows and 78 columns as it takes hours to calculate
despite my computer being high spec with an i9 16 core processor, 64 GB Ram and a 1TB Evo SSD
it maxes out my CPU and will need helper columns.
Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015
Commented:
Yes, I agree. For that much of large data set, helper columns would be the best approach.
BTW good system configuration. I wish, one day I will have a system with same configuration. Let me know if you ever want to exchange your system with less powered system like mine. Lol
retired

Commented:
Thanks again Neeraj.
I think my computer is too heavy to ship :)
Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
You're welcome Ian!

I think my computer is too heavy to ship :)
LOL...

Do more with