![]() |
|
|
|||||||
| 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: Apr 2002
Posts: 17
|
I cells A1:A3 I have the numbers 5,0,5 respectivly. In Cell A4, I have the formula Average(A1:A3). I want the zero value to be ignored in the calculation, so that the result of the average is "5". Data is continuously added to the spreadsheet, and I never know which of the cells will have a zero value, so just averaging cells A1 and A3 is not an option.
Any ideas? |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
Note: This is an array formula which must be entered using the Control+Shift+Enter key combination. |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Posts: 17
|
Thanks, that works perfectly.....but why? I don't get it. Why was the zero ignored using that array formula?
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Calgary, Alberta Canada
Posts: 2,100
|
Array enter (Ctrl-Shift-Enter)one of the following: =IF(COUNTIF(A1:C1,">0"),AVERAGE(IF(A1:C1=0,"",A1:C1)),"") =IF(COUNTIF(A1:C1,">0")=0,"",AVERAGE(IF(A1:C1=0,"",A1:C1))) =AVERAGE(IF(A1:C1,A1:C1)) gives error if all numbers are 0. |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 51,549
|
An efficient formula would be: =SUM(A1:A3)/MAX(1,COUNT(A1:A3)-COUNTIF(A1:A3,0)) |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
How about just =SUM(A1:A3)/COUNTIF(A1:A3,">0") Regards! |
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 51,549
|
Quote:
|
|
|
|
|
|
|
#8 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Quote:
=SUM(A1:A3)/COUNTIF(A1:A3,"<>0") regards! |
|
|
|
|
|
|
#9 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
[ This Message was edited by: Mark W. on 2002-05-12 15:05 ] |
|
|
|
|
|
|
#10 |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 51,549
|
=SUM(A1:A3)/COUNTIF(A1:A3,"<>0") Try: {0;0;0} which are real 0's. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|