Calculating an Average of Visible Cells

Written by Allen Wyatt (last updated June 27, 2026)

1

Gary routinely filters data in a worksheet based on various criteria. He would like to calculate an average of the visible values in column C. In other words, when he filters the data, he wants the average of what is visible in column C after the filter is applied. Gary tried the AVERAGE function, but it seems to apply to all cells in column C regardless of their visibility.

There are several ways you can accomplish the task. First, Gary could convert his data to formal table and then add a total row. You can then select the total shown in column C, click the down-arrow next to the total, and choose Average. This will average just the visible values in the table, which is exactly what Gary wants.

The way that adding an average in a formal table is accomplished leads to the next option: using the SUBTOTAL function. If you perform the above steps for a formal table, you can see that Excel calculates the average using this function:

=SUBTOTAL(101,[Amount])

The second parameter is the name of the table column being averaged. There are two things to note here, however. First, SUBTOTAL doesn't work with just formal tables. You can specify a range that should be averaged by using the second parameter:

=SUBTOTAL(101,C2:C1000)

This means that the SUBTOTAL approach works great if you need your average somewhere else besides in a total row.

The second thing to note is the first parameter, in this case 101. The general idea of this parameter is to specify what you want returned by SUBTOTAL. If you want an average returned (as does Gary), then you can use a first parameter value of either 1 or 101. The difference between the two is in how SUBTOTAL handles manually hidden rows. If the value is 1, then manually hidden rows are included in the average. If the value is 101, then manually hidden rows are excluded from the average.

Understand that filtered rows are always ignored by SUBTOTAL; the first parameter only deals with manually hidden rows. This can cause some seemingly wonky results if your data includes both filtered rows and manually hidden rows. In that case, SUBTOTAL ignores all hidden rows, regardless of whether you use 1 or 101 as your first parameter.

If you are using Excel 2010 or a later version, you can use the AGGREGATE function instead of SUBTOTAL. Why would you want to do this? Primarily because AGGREGATE offers better control over what should be excluded from your average and it natively works with other array-based functions. There are three parameters that should be specified with AGGREGATE, in this manner:

=AGGREGATE(1,3,C2:C1000)

The first parameter indicates you want an average returned by the function. The second parameter indicates what you want to exclude from the calculation, as follows:

Option What to Ignore
0 SUBTOTAL and AGGREGATE functions
1 Hidden rows and SUBTOTAL and AGGREGATE functions
2 Error values and SUBTOTAL and AGGREGATE functions
3 Hidden rows, error values, and SUBTOTAL and AGGREGATE functions
4 Nothing
5 Hidden rows
6 Error values
7 Hidden rows and error values

To the AGGREGATE function, it doesn't matter how rows are hidden; filtered rows and manually hidden rows are treated the same. Whereas SUBTOTAL always excludes filtered rows, AGGREGATE only excludes them (along with manually hidden rows) if you set the second parameter to 1, 3, 5, or 7.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13557) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365.

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. ...

MORE FROM ALLEN

Printing to a File

Word allows you to send your output to a file instead of to a printer. This tip shows you how.

Discover More

Deleting a File in a Macro

Macros give you a great deal of control over creating, finding, renaming, and deleting files. This tip focuses on this ...

Discover More

Easily Changing Print Order

You can change the order in which pages are printed (normal or reversed) using the Print dialog box or the print settings ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Specifying a Date Range in a SUMIFS Formula

The SUMIFS function allows you to specify criteria by which values can be included in a sum. Putting together the ...

Discover More

Converting Codes to Characters

Character codes are the numeric values used, by a computer, to signify various alphanumeric characters. You can use the ...

Discover More

Colors in an IF Function

You can use the IF worksheet function to test for a number of different conditions or values. You can't use it to check ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

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}] (all 7 characters, in the sequence shown) 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 more than 9?

2026-06-27 11:21:55

J. Woolley

Here's another way, but it yields a static result:
1. Right-click the status bar and make sure Average is checked. (This does not need to be repeated.)
2. Select the range containing filtered cells.
3. The status bar includes an item labeled "Average: X" where X is the result.
4. Double-click the item labeled "Average: X" to copy the result to the clipboard.
5. Press Ctrl+V to paste the result where needed.


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
Subscribe

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.