Average cells >0

Tikey

Board Regular
Joined
Jan 30, 2014
Messages
109
Office Version
  1. 2019
Platform
  1. Windows
Hi

I wish to average a number of cells, but only if all the cells in the range are >0. I have tried using =AVERAGEIF(A1:A5 ,">0"), but this includes any odd cells that are >0 and in the first example below, gives an answer of 3 when it should be 0. The second example shows the result should only be when all values are > 0.

AA
1​
0​
1​
2​
2​
0​
2​
2​
3​
0​
3​
2​
4​
0​
4​
2​
5​
3​
5​
2​
Answer Required
0​
2​
Maybe this should be easy, but I cannot find a solution, any help appreciated.
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
4,426
Office Version
  1. 365
Platform
  1. MacOS
perhaps
= IF ( Countif(A1:A5, 0)>0, "" , Average(A1:A5) )
 

jmacleary

Well-known Member
Joined
Oct 5, 2015
Messages
1,054
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
Hi there. Does this do the job? NB The formulas are array formula so need entering with ctrl-shift-enter.
Book3 (version 1).xlsb
AB
110
220
330
440
553
630
Sheet3
Cell Formulas
RangeFormula
A6:B6A6=IF(A1:A5>0,AVERAGE(A1:A5),0)
Press CTRL+SHIFT+ENTER to enter array formulas.
 

Tikey

Board Regular
Joined
Jan 30, 2014
Messages
109
Office Version
  1. 2019
Platform
  1. Windows
etaf

Thanks for your reply, this works but does not display the 0 in the answer as in my example 1. Maybe I'm doing something wrong.
 

Tikey

Board Regular
Joined
Jan 30, 2014
Messages
109
Office Version
  1. 2019
Platform
  1. Windows

ADVERTISEMENT

jmacleary

Thanks for your reply, unfortunately this appears to still provide an average when one of the cells is 0.
 

JimM

Well-known Member
Joined
Nov 11, 2003
Messages
686
Not wishing to steal etaf's thunder but just swap out the "" with 0

ie
= IF ( Countif(A1:A5, 0)>0, 0 , Average(A1:A5) )
 

jmacleary

Well-known Member
Joined
Oct 5, 2015
Messages
1,054
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
jmacleary

Thanks for your reply, unfortunately this appears to still provide an average when one of the cells is 0.
Yes, you're right - I didn't test it properly. You can use etaf's answer slightly modified like:
=IF(COUNTIF(A1:A5,0)>0,0,AVERAGE(A1:A5))
to get the zeroes you want.
 

Tikey

Board Regular
Joined
Jan 30, 2014
Messages
109
Office Version
  1. 2019
Platform
  1. Windows
Everyone, thanks all your replies, problem sorted, much appreciated.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,320
Messages
5,600,935
Members
414,417
Latest member
Nobu

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
Top