How to Average in Excel Excluding Hidden Rows

How-to basics · Updated December 1, 2026

The quickest way to average visible cells only is to use the SUBTOTAL function with function number 101 (AVERAGE). For example, if your numbers are in A2:A20, enter =SUBTOTAL(101,A2:A20). This function automatically ignores rows hidden by filtering or by manually hiding rows. If you need a conditional average that also skips hidden rows, combine SUBTOTAL with IF inside an array formula, or use the newer AGGREGATE function. This guide covers both approaches, what to prepare, common errors, and how to fix them.

What You’ll Need

  • Microsoft Excel for Microsoft 365 on Windows (steps for Mac and Excel for the web are noted where they differ).
  • A worksheet with numeric data in a column or row, and some rows you plan to hide or filter.
  • Basic familiarity with entering formulas in a cell.

Step-by-Step

Method 1: Average visible rows with SUBTOTAL (simplest)

  1. Open your worksheet and confirm the numbers you want to average are in a single column, say A2:A20. If your data is in a row, adjust the range accordingly (e.g., B2:H2).
  2. Click an empty cell where you want the average to appear, for example C2.
  3. Type =SUBTOTAL(101,A2:A20) and press Enter. The 101 is the AVERAGE function code that tells SUBTOTAL to ignore rows hidden manually or by a filter. (Code 1 would include hidden rows, so do not use it.)
  4. Test it: right-click a row number (e.g., row 5) and choose Hide. The average in C2 updates to exclude that row’s value. Unhide by selecting rows 4 and 6, right-clicking, and choosing Unhide.
  5. If you apply a filter (Data > Filter), the SUBTOTAL formula also ignores rows that the filter hides. This is the same behavior as the status bar average when you select visible cells.

Method 2: Average visible rows with AGGREGATE (more control)

  1. Use AGGREGATE when you want to ignore not only hidden rows but also error values. The syntax is =AGGREGATE(1,7,A2:A20) where 1 is AVERAGE and 7 means ignore hidden rows and error values.
  2. Enter =AGGREGATE(1,7,A2:A20) in a cell. This works in Excel 2010 and later, so it is available in Microsoft 365, Excel 2021, and Excel 2019.
  3. Unlike SUBTOTAL, AGGREGATE will not be affected by a filter if you use option 7? Actually, option 7 ignores hidden rows, but it does not respect filter hiding in all cases. For filtered data, SUBTOTAL is more reliable. Use AGGREGATE mainly for manually hidden rows or when you have errors in the range.

Method 3: Average visible rows that meet a condition (advanced)

  1. Suppose you have categories in B2:B20 and numbers in A2:A20, and you want the average of visible numbers where category is “North”. Start by entering the condition in a cell, say D1: North.
  2. In an empty cell, enter this array formula (for Microsoft 365, it works normally; for older Excel, press Ctrl+Shift+Enter):
    =AVERAGE(IF(SUBTOTAL(3,OFFSET(A2,ROW(A2:A20)-ROW(A2),0,1))>0,IF(B2:B20=D1,A2:A20)))
    This uses SUBTOTAL with function 3 (COUNTA) to check each row’s visibility, then averages only visible rows that also match the condition.
  3. Press Enter. In Microsoft 365, dynamic arrays handle this automatically. In Excel 2019 or earlier, you must confirm with Ctrl+Shift+Enter; you will see curly braces {} around the formula in the formula bar.
  4. Hide a row that has “North” in column B and watch the average recalculate. If you get a #VALUE! error, you likely forgot to confirm as an array formula in older Excel.

Method 4: Average visible cells only using a helper column (no array formula)

  1. Add a new column, say C, and in C2 enter =SUBTOTAL(103,A2). The 103 is COUNTA for visible cells. Drag this down to C20. This returns 1 for visible rows and 0 for hidden rows.
  2. Now use AVERAGEIFS to average only rows where the helper column equals 1: =AVERAGEIFS(A2:A20,C2:C20,1).
  3. This method works with manually hidden rows and with filters. It is easier to understand than the array formula and works in all Excel versions.

Common Mistakes

  • Using the plain AVERAGE function: =AVERAGE(A2:A20) always includes hidden rows. It does not ignore them.
  • Using SUBTOTAL with code 1 instead of 101: Code 1 includes hidden rows. Codes 101-111 are the “ignore hidden” versions. For average, you must use 101.
  • Forgetting that filters and hidden rows are different: SUBTOTAL with 101 ignores both, but AGGREGATE with option 5 (ignore hidden rows) does not ignore filter-hidden rows in all cases. Test with your data.
  • Array formula not confirmed with Ctrl+Shift+Enter (in Excel 2019 and earlier): If you just press Enter, you get a #VALUE! error or a wrong result.
  • Including header rows in the range: If A1 is a text header, SUBTOTAL will ignore text automatically, but if you have numbers in the header, it will skew the average.

Tips

  • To quickly see the average of visible cells without a formula, select the visible numbers and look at the status bar at the bottom-right; it shows Average, Count, and Sum for the selected visible cells only.
  • If you hide rows manually, SUBTOTAL(101,…) updates immediately. If you use a filter, it also updates. No need to recalculate manually.
  • For a dynamic range that grows, use a table (Insert > Table) and reference the column name, e.g., =SUBTOTAL(101,Table1[Sales]). This automatically includes new rows.
  • On a Mac, the same functions work; keyboard shortcuts differ for hiding rows (Cmd+9) and unhiding (Cmd+Shift+9).
  • In Excel for the web, SUBTOTAL and AGGREGATE work, but array formulas with Ctrl+Shift+Enter are not needed; they work as dynamic arrays.

Troubleshooting

  • The average does not change when I hide a row: Check that you used 101, not 1. Also ensure the row is truly hidden (right-click > Hide), not just collapsed in a group (which also works, but only if you used 101).
  • I get a #DIV/0! error: This means all rows are hidden, or the range contains no visible numbers. Unhide some rows or check that the range has at least one visible numeric cell.
  • I get #VALUE! with the array formula: In Excel 2019 or older, you must press Ctrl+Shift+Enter after typing the formula. In Microsoft 365, just press Enter. Also check that the ranges match in size (A2:A20 and B2:B20).
  • AGGREGATE ignores hidden rows but not filters: For filtered data, use SUBTOTAL(101,…) instead. AGGREGATE option 7 ignores hidden rows and errors, but filter hiding is not always respected. Use SUBTOTAL for filters.
  • The average includes the header: If your range includes a header with a number, exclude it. For example, use A2:A20 instead of A1:A20.
  • I want to average visible cells in multiple columns: SUBTOTAL can handle a 2D range like =SUBTOTAL(101,A2:C20), but it averages all visible cells in that rectangle, not per column. For per-column averages, use separate formulas.

Frequently Asked Questions

Does AVERAGEIF ignore hidden rows?

No. AVERAGEIF and AVERAGEIFS only consider the condition, not visibility. They include hidden rows. To exclude hidden rows, you must use SUBTOTAL or the helper column method.

Can I use SUBTOTAL with multiple conditions?

No, SUBTOTAL only takes a single function code and a range. For multiple conditions, use the helper column with AVERAGEIFS, or the array formula shown above.

What is the difference between SUBTOTAL and AGGREGATE?

SUBTOTAL is simpler and respects filters automatically. AGGREGATE offers more options (like ignoring errors) and can use function codes 1-19, but its hidden-row behavior with filters is less reliable. For most cases, SUBTOTAL is the right choice.

Will the average update if I filter using a slicer?

Yes. Slicers apply filters, and SUBTOTAL(101,…) will ignore rows hidden by the slicer, just like a regular filter.

How do I average visible rows in a row (horizontal data)?

Use the same SUBTOTAL formula with a horizontal range, e.g., =SUBTOTAL(101,B2:H2). It works for rows as well as columns.

Can I use this in a pivot table?

Pivot tables already exclude hidden items when you filter them. If you want a formula outside the pivot, use GETPIVOTDATA or reference the pivot’s visible values, but SUBTOTAL on the source data will not reflect pivot filters.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.