![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 32
|
How do I write a formula to average about 10 specific cells but I need to exclude any 0's from the average?
Example: Average cells A1, C1, D3, F4, G5 but if any one of those is a zero I don't want it to be included because it will skew the average. Thanks! |
|
|
|
|
|
#2 |
|
MrExcel MVP, Administrator
Join Date: Feb 2002
Location: The act or process of locating.
Posts: 13,679
|
In the cell where you want the average to be, type =AVERAGE(
Then, hold down control and click on all of the cells you wish to average. You can leave out any cells you want. When you have all of the cells selected, close your parenthesis (add the ")" to the end) and press enter. |
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Posts: 32
|
Thanks. It's a varying sheet though, meaning some days there will be a zero in the cell and other days the same cells will have a value. I need something that can dynamiclly change to exclude any zeros that may be in the cells. Any ideas on how to exclude zeros? Again, thanks.
|
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
{=AVERAGE(IF(H1:H5,H1:H5))} Note: Array formulas must be entered using the Control+Shift+Enter key combination. The outermost braces, { }, are not entered by you -- they're supplied by Excel in recognition of a properly entered array formula. [ This Message was edited by: Mark W. on 2002-03-15 09:40 ] |
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Feb 2002
Posts: 32
|
I have completed the formula exactly as you stated and excel enclosed the formula with the {} to recognize the properly entered array formula. However, the value of the cell gives me the #VALUE! message. Any suggestions? Thank you!
|
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
|
Q,
is the range size and location static, just some could be 0 and some could have numbers in them ? |
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
After creating a range of consecutive cells, would =SUM(H1:H5)/MAX(1,COUNTIF(H1:H5,">0")+COUNTIF(H1:H5,"<0")) do the job. Aladin |
|
|
|
|
|
|
#8 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
|
Quote:
Forever curious..... [ This Message was edited by: Chris Davison on 2002-03-15 15:54 ] |
|
|
|
|
|
|
#9 | ||
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
SUM([multi-cell-range]*,[single-cell-range]*) COUNTIF(a-multi-or-single-cell-range,condition) A named range of non-contiguous cells (say "table") used in =sum(table) will give a number, because the underlying syntax supports it, while that of countif does not. Names thus does not add an enrichment to the syntax the functions require. I'd say that's just right. =countif(table,">0") should give indeed a #VALUE error, indicating that the function is fed with a range arg which it does not support. Aladin |
||
|
|
|
|
|
#10 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
|
thanks,
a subtle, albeit unfortunate syntax difference ! |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|