Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: An Average that Excludes Zero Values.

An Average that Excludes Zero Values

by Allen Wyatt
(last updated October 28, 2017)


Veronica knows how to use the AVERAGE function to determine the average of a range of values. She would like to have the average determined based on the non-zero values in the range, however.

The worksheet function most suited to this purpose is to use AVERAGEIF. You can use it in this manner:


This function only includes in the average those cells that contain values greater than zero. If you want to also exclude blank cells, you should use the AVERAGEIFS function. This function differs from AVERAGEIF in that it allows you to specify multiple criteria that indicate which cells to average.


Of course, if you want to approach the problem "old school" (without using AVERAGEIF or AVERAGEIFS), then there are several ways you can proceed. The first is to remember how an average is calculated. It is defined as the sum of a range of values divided by the number of items in the range. Thus, you could figure the exclusionary average by simply making sure that the denominator (the number you are dividing by) does not include any zero values. For instance:


This approach uses the COUNTIF function to determine the number of cells in the range (A1:A50) that don't contain zero. If this range contains not only zeros but also blank cells, and you don't want the blank cells figured into the result, then you need to use a more complex formula:


The COUNTIF function counts cells that do not explicitly evaluate to 0, but it will count blank and text cells. The COUNTBLANK term adjusts for the blank cells and the difference between COUNTA and COUNT adjusts the total count for cells that contain text.

Of course you can also use an array formula to do your calculation:


Remember that array formulas need to be entered by using the combination Ctrl+Shift+Enter. This array formula also excludes blanks or cells containing text.

All in all it is easier to use the AVERAGEIF or AVERAGEIFS functions. When would you not want to use them? When you need to share your workbook with users of Excel versions prior to Excel 2007. (This is when the functions were added to Excel.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7729) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: An Average that Excludes Zero Values.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Relative VBA Selections

Need to select a cell using a macro? Need that selection to be relative to the cell you currently have selected? Here's ...

Discover More

Cascading Document Windows

Want the various documents you have open to be cascaded on-screen so you can organize them easier? The capability is ...

Discover More

Using the Status Bar

When developing a macro, you may want to display on the status bar what the macro is doing. Here's how to use this ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Excluding Values from Averaging

Calculating an average of a group of numbers is easy. What if you want to exclude a couple of the numbers from the group ...

Discover More

Averaging the Last Numbers in a Column

Need to calculate a running average for the last twelve values in a constantly changing range of values? The formula ...

Discover More

Averaging a Non-Contiguous Range

Figuring out how to average data that is in a contiguous range of cells is easy. When the data is spread over a group of ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is eight less than 8?

2018-10-10 09:40:03


Thank you!!!! This solved my formula problem!!!!

2018-06-16 18:56:37

C Lee

Soooooo...let's say that I am setting up a simple average cost of stock shares purchased with a different number of shares bought at different prices. In column A rows 2 through 6 the # of shares is entered and in column B in rows 2 through 6 the price of those shares bought is entered.

# of shares bought Price
100 14.25
200 14.75
500 13.22
blank blank
blank blank

If there were only three entries allowed and all three entries for the # of shares bought and price had to be filled in the formula would be the following:
=SUMPRODUCT( A2:A4, B2:B4 ) / SUM( B2:B4 )

But, if I want to allow for up to 5 buys and sometimes only needed 3 buys how do I not count the remaining 2 buys if those cells are blank?

Apparently, there is no SUMPRODUCTIFS to use as

=SUMPRODUCTIFS( A2:A6, A2:A6,">0",A2:A6,"<>""",B2:B6,B2:B6,">0",B2:B6,"<>""") / SUM( B2:B6,B2:B6,">0",B2:B6,"<>""")

Getting the #NAME? for this....

Any thoughts???

2018-03-14 14:20:36


What if you are trying to get an average excluding 0 values or blank cells and the range is derived from a non-consecutive set of cells within a column? For example, I want to get the average of cells C9, C17, C25, C33, C41, C49, C57, C65, C73, C81 excluding 0 values or blank cells. The cells between these include numerical information that I do not want included in the average and the C9:C81 command would include them.




These both would not work because of the non-consecutive cells that I am using in a column for the data.

2017-12-14 11:44:00

Flux Capacitor

How would I use AVERAGEIF in combination with the SUBTOTAL function, to dynamically calculate the average of non-zero values depending on filter selections?

2017-10-28 07:42:07

Elliot Penna

Great to know about the AVERAGEIF function! It seems to already exclude cells with blanks, text, and zeroes, simply with the format of:

=AVERAGEIF([range],">0") or =AVERAGEIF([range],"<>0")

No coding calisthenics required! At least not with my version of Excel (2010).

This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.