average values in non-contiguous cells, ignoring 0 values

R

RWormdahl

How do I average the values in non-contiguous cells, while ignoring cells
with 0 values? I tried the average function, but the IF conditional seems to
recognize only contiguos cells. I keep getting the "The formula you entered
contains an error..." message, and cannot execute the F2 ctl+shift+enter
command.
Any ideas?
 
J

JMB

One way, assuming the noncontiguous range is G7:G9,G12:G14

=SUM(G7:G9,G12:G14)/SUMPRODUCT((G7:G9<>0)+(G12:G14<>0))
 
J

JMB

Or it could be modified

SUM(G7:G9,G12:G15)/(SUMPRODUCT(--(G7:G9<>0))+SUMPRODUCT(--(G12:G15<>0)))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top