# I need to calculate the averages of a range without counting

#### afs24

##### Board Regular
I'm trying to calculate the average of a range of cells with the numbers (ex: 200,300,0,0). The answer should be 250 not 125 when dividing by 4. Zero shouldn't count because there's always a number for in spreadsheet. I'm adding up the sum of the four numbers and dividing it by the count but it's counting the zero? HELP????

### Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

##### MrExcel MVP
Let A2:A10 house the numbers of interest.

=SUM(A2:A10)/MAX(1,COUNT(A2:A10)-COUNTIF(A2:A10,0))

will produce the desired average of non-zero numbers.

#### VoG

##### Legend
With your numbers in A1 to A4, in A5

=SUMIF(A1:A4,">0")/4

gives 125

#### plettieri

##### Well-known Member
In the answer supplied by Vog(tm), if one of the numbers in the data base is less than 0 the answer would be different than in the answer supplied by Aladin. Also if the quantify of data is different than 4, you would have to modify that to the new total data counts .....Aladin's answer seem to account for both issue within the formular.

pll

#### VoG

##### Legend

Good point plettieri.

=SUMIF(A1:A4,"<>0")/4

works correctly with negative numbers.

##### MrExcel MVP
[...]

=SUMIF(A1:A4,"<>0")/4

works correctly with negative numbers.

The question afs24 posed is:

[/quote]I'm trying to calculate the average of a range of cells with the numbers (ex: 200,300,0,0). The answer should be 250 not 125 when dividing by 4. Zero shouldn't count...[/b]

The SUMIF formula doesn't satisfy the requirements: It would just produce 125 as average when applied to: {200,300,0,0} entered in A1:A4, while

=SUM(A1:A4)/MAX(1,COUNT(A1:A4)-COUNTIF(A1:A4,0))

will produce the desired average of 250.

This formula "works correctly with negative numbers" too, as it should:

Enter {-200,300,0,0} in A1:A4...

The result should be 50 by afs24's specs.

#### VoG

##### Legend

Thank you. I must learn to read and think before posting (twice!).

P.S. this does work

=SUMIF(A1:A4,"<>0")/COUNTIF(A1:A4,"<>0")
This message was edited by VoG™ on 2002-09-29 08:28 Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

### Forum statistics

1,164,088
Messages
5,835,314
Members
430,351
Latest member
ddalton ### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?    1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option. Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com". Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button. Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button. Go back