Sum cells unless a cell = 0

RodneyC

Active Member
Joined
Nov 4, 2021
Messages
278
Office Version
  1. 2016
Platform
  1. Windows
I'm using this formula

=SUM($E4:$Q4)/12

to sum the values in a row. For some of the rows, some of the values in E:Q are 0. If that is the case, I want the value 12 to change to however many values E:Q are greater than 0. Example, if only 8 of the values E:Q were greater than 0 then the formula would change the 12 to an 8.

Make sense?

Thanks in advance
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
=SUM(E4:Q4)/COUNT(E4:Q4)

or just

=AVERAGE(E4:Q4)

Also, E:Q is 13 columns. Not sure that makes a difference.
 
Upvote 0
how about

=SUM($E4:$Q4)/COUNTIF($E4:$Q4,">"&0)
 
Upvote 0
I'm using this formula

=SUM($E4:$Q4)/12

to sum the values in a row. For some of the rows, some of the values in E:Q are 0. If that is the case, I want the value 12 to change to however many values E:Q are greater than 0. Example, if only 8 of the values E:Q were greater than 0 then the formula would change the 12 to an 8.

Make sense?

Thanks in advance
This can be too...
=SUM(E4:Q4)/COUNTIFS($E$4:$Q$4,"<>0")
 
Upvote 0
Also bear in find that if you do not have any values in columns E:Q, you will get a #DIV/0 error message.

You can fix that by wrapping whatever formula you choose to use in an IFERROR function, i.e.
=IFERROR(your formula,"")
 
Upvote 0
thanks everyone, I went with this becauase it was the first one I saw: =SUM($E4:$Q4)/COUNTIF($E4:$Q4,">"&0)
 
Upvote 0
What about the single function designed exactly for that sort of thing?
Excel Formula:
=AVERAGEIF($E4:$Q4,">0")
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,293
Members
449,077
Latest member
Rkmenon

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