If cells in a range are zero prevent sumproduct and sum from DIV/0 error

DeezNuts

Board Regular
Joined
Aug 12, 2014
Messages
177
How can I fix this formula so if none of the 5 cells in the range have a number value this formula doesnt give an error but displays a - instead. The 5 cells show a - when no value is them. J21 is the formula I am having the problem with


Excel 2013
EFGHIJK

<tbody>
[TD="align: center"]20[/TD]
[TD="bgcolor: #D9D9D9, align: center"][/TD]
[TD="bgcolor: #FFFFFF, align: center"][/TD]
[TD="bgcolor: #D9D9D9, align: center"][/TD]
[TD="bgcolor: #FFFFFF, align: center"][/TD]
[TD="bgcolor: #D9D9D9, align: center"][/TD]
[TD="align: center"]Grade[/TD]
[TD="align: right"][/TD]

[TD="align: center"]21[/TD]
[TD="bgcolor: #D9D9D9, align: center"]-[/TD]
[TD="align: center"]-[/TD]
[TD="bgcolor: #D9D9D9, align: center"]87.00[/TD]
[TD="align: center"]-[/TD]
[TD="bgcolor: #D9D9D9, align: center"]-[/TD]
[TD="bgcolor: #548235, align: center"]87.00[/TD]
[TD="bgcolor: #548235, align: center"]A[/TD]

</tbody>


[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]E21[/TH]
[TD="align: left"]=IF(COUNT(E3:E20),AVERAGE(E3:E20),"-")[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]F21[/TH]
[TD="align: left"]=IF(COUNT(F3:F20),AVERAGE(F3:F20),"-")[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]G21[/TH]
[TD="align: left"]=IF(COUNT(G3:G20),AVERAGE(G3:G20),"-")[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]H21[/TH]
[TD="align: left"]=IF(COUNT(H3:H20),AVERAGE(H3:H20),"-")[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]I21[/TH]
[TD="align: left"]=IF(COUNT(I3:I19),AVERAGE(I3:I20),"-")[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]K21[/TH]
[TD="align: left"]=LOOKUP(J21,AG1:AG18,AH1:AH18)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]J21[/TH]
[TD="align: left"]{=SUMPRODUCT(AE3:AE7,AF3:AF7)/SUM(IF(AF3:AF7<>"-",AE3:AE7))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
sorry forgot I had another issue and had moved where this code was getting its data. Here is a mini version of it. The %'s at the top are the weights the blanks between the %'s and the - are where the grades would go


Excel 2013
RSTUVW

<tbody>
[TD="align: center"]24[/TD]
[TD="align: center"]20%[/TD]
[TD="align: center"]22%[/TD]
[TD="align: center"]8%[/TD]
[TD="align: center"]45%[/TD]
[TD="align: center"]5%[/TD]
[TD="align: center"][/TD]

[TD="align: center"]25[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]26[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]27[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]28[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]29[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]30[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]

[TD="align: center"]31[/TD]
[TD="align: center"]-[/TD]
[TD="align: center"]-[/TD]
[TD="align: center"]-[/TD]
[TD="align: center"]-[/TD]
[TD="align: center"]-[/TD]
[TD="align: center"]#DIV/0![/TD]

</tbody>


[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]R31[/TH]
[TD="align: left"]=IF(COUNT(R25:R30),AVERAGE(R25:R30),"-")[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]S31[/TH]
[TD="align: left"]=IF(COUNT(S25:S30),AVERAGE(S25:S30),"-")[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]T31[/TH]
[TD="align: left"]=IF(COUNT(T25:T30),AVERAGE(T25:T30),"-")[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]U31[/TH]
[TD="align: left"]=IF(COUNT(U25:U30),AVERAGE(U25:U30),"-")[/TD]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]V31[/TH]
[TD="align: left"]=IF(COUNT(V25:V30),AVERAGE(V25:V30),"-")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]W31[/TH]
[TD="align: left"]{=SUMPRODUCT(R24:V24,R31:V31)/SUM(IF(R31:V31<>"-",R24:V24))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
In words please, not by means of (non-working) formulas...

Try to post an appropriate sample along with the expected results based on that sample.
 
Upvote 0
how can i fix this formula so if none of the 5 cells in the range have a number value this formula doesnt give an error but displays a - instead.
Rich (BB code):
{=sumproduct(r24:v24,r31:v31)/sum(if(r31:v31<>"-",r24:v24))}
 
Upvote 0
Nevermind I used a iferror figured there was better way of doing it. No idea how to explain it any differently.
Code:
=IFERROR( SUMPRODUCT(E2:I2,E21:I21)/SUM(IF(E21:I21<>"-",E2:I2)),"-")
 
Upvote 0
Nevermind I used a iferror figured there was better way of doing it. No idea how to explain it any differently.
Code:
=IFERROR( SUMPRODUCT(E2:I2,E21:I21)/SUM(IF(E21:I21<>"-",E2:I2)),"-")

Use words, not formulas... Not change references continually...

Just enter:

=IFERROR(SUMPRODUCT(E2:I2,E21:I21)/SUMIF(E21:I21,"<>-",E2:I2),"-")
 
Upvote 0

Forum statistics

Threads
1,224,427
Messages
6,178,587
Members
452,860
Latest member
jroberts02

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