I want to calculate the average of, let’s say, four cells.
Basic.
But if one or more cells in the range are zero, I don’t want these cells to a part of the calculation.
How could the formula be constructed ?
Saturn
I want to calculate the average of, let’s say, four cells.
Basic.
But if one or more cells in the range are zero, I don’t want these cells to a part of the calculation.
How could the formula be constructed ?
Saturn
Last edited by Saturn; 07-10-2011 at 10:15 AM.
Hi, an array formula
to be confirmed with control+shift+enter.=AVERAGE(IF(A1:A100,A1:A100))
Regards
Edit: I'd left a ";" in the formula.
Last edited by canapone; 07-10-2011 at 10:15 AM.
Great!! An array is the solution.
It works.
Thanks a lot
=sum(a1:a100)/countif(a1:a100,"<>"&0)
"Unless otherwise stated all my comments are directed at OP"
Mojito connoisseur and now happily retired
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
Thanks again
The last one is good if the cells actually contains zero's and is not just blank.
Another good option.
Saturn
You can also use AVERAGEIF function
=AVERAGEIF(A1:A4,"<>0")
Audere est facere
I have all most the same problem. I'm trying to average a value in b2 plus a different sheet (bills) c2:ab2 and not average in cells that contain a zero. Here is how I have the formula:
=averageif(b2,bills!c2:ab2,"<>0") what I get is a dialog box saying error in formula and it highlights b2 in the formula. If I remove b2 from the formula it works.
=averageif(bills!c2:ab2,"<>0") . Any idea on whats going on?
jim
Last edited by jlr4; 08-24-2011 at 05:28 PM.
you should start your own thread linking to this one if needed
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks