Average non-contiguous cells, ignoring zeros (1 Viewer)

bobfin

Registered User.
Local time
Today, 15:25
Joined
Mar 29, 2002
Messages
82
I have a large spreadsheet where B46 =AVERAGE(G42,L42,Q42). But if any of the values are zero, I want the average to ignore the cell (divide by 2 or 1 instead of 3). There's an Excel help topic on this situation that averages the range A2:A7 with the array formula {=AVERAGE(IF(A2:A7<>0,A2:A7,""))}. How do I write the formula for my non-contiguous cells?
 

shades

Registered User.
Local time
Today, 09:25
Joined
Mar 25, 2002
Messages
516
Howdy. You could use an IF statement combined with COUNTIF and then use the average based on that.
________
Stobart motorsport
 
Last edited:

Brianwarnock

Retired
Local time
Today, 15:25
Joined
Jun 2, 2003
Messages
12,701
I'm not sure how that would work, but you could use Sum and If

average =Sum(g42,l42,q42)/sum(if(g42=0,0,1),if(l42-0,0,1),if(q42=0,0,1))


wouldn't like to write it for many cells. :)

Brian
 

lemo

Registered User.
Local time
Today, 10:25
Joined
Apr 30, 2008
Messages
187
another possibility - in the excel options there is a check to show zeros as zeros. if you uncheck it, there will be blanks instead. which will solve your problem - but at the expense of those zeros..
l
 

shades

Registered User.
Local time
Today, 09:25
Joined
Mar 25, 2002
Messages
516
Will that eliminate the issue though, because the average is still counting number of cells? (I don't have Excel currently, so can't check).
 

Brianwarnock

Retired
Local time
Today, 15:25
Joined
Jun 2, 2003
Messages
12,701
Rich
I think, well feel pretty sure, that average ignores blanks, but think I will check.

Brian

Edit yep it does.
 

lemo

Registered User.
Local time
Today, 10:25
Joined
Apr 30, 2008
Messages
187
ok, i think there is a problem - when you show blanks instead of zeros (through Excel Options), the ZEROS ARE STILL THERE, they are just hidden. like their font is white.

my apologies. i projected this feature from pivot tables, i guess, where it works just fine..

this is for Excel 2007, btw, you may want to double check how it behaves in the previous version.

l
 

Users who are viewing this thread

Top Bottom