The SUBTOTAL function number is the first argument you pass to SUBTOTAL, and it tells Excel which operation to perform (SUM, AVERAGE, COUNT, etc.) and whether to ignore hidden rows. The numbers are 1–11 for the basic functions and 101–111 for the same functions that also ignore manually hidden rows.
What the SUBTOTAL Function Does
SUBTOTAL is a versatile Excel function that calculates a result (like sum or average) from a range of cells, but with two special behaviors:
- It can ignore rows hidden by a filter (when you use the 1–11 codes).
- It can ignore rows hidden manually (when you use the 101–111 codes).
This makes it ideal for use with filtered tables, outlines, or dashboards where you want totals to update automatically when data is hidden.
The Complete List of Function Numbers
Here are all the function numbers you can use, with the corresponding Excel function they replicate:
- 1 or 101 – AVERAGE
- 2 or 102 – COUNT (counts numbers)
- 3 or 103 – COUNTA (counts non-empty cells)
- 4 or 104 – MAX
- 5 or 105 – MIN
- 6 or 106 – PRODUCT
- 7 or 107 – STDEV (sample standard deviation)
- 8 or 108 – STDEVP (population standard deviation)
- 9 or 109 – SUM
- 10 or 110 – VAR (sample variance)
- 11 or 111 – VARP (population variance)
Note: The 101–111 codes ignore rows that are hidden manually (right-click → Hide) as well as rows hidden by a filter. The 1–11 codes ignore only rows hidden by a filter, not manually hidden rows.
How to Use SUBTOTAL with a Function Number
The syntax is: =SUBTOTAL(function_num, ref1, [ref2], ...)
For example, to sum values in cells A2:A10 while ignoring rows hidden by a filter, use:
=SUBTOTAL(9, A2:A10)
To average the same range while ignoring manually hidden rows as well, use:
=SUBTOTAL(101, A2:A10)
You can also reference multiple ranges: =SUBTOTAL(9, A2:A10, C2:C10) – this sums both ranges together.
Choosing Between 1–11 and 101–111
The key difference is how Excel treats manually hidden rows. If you hide rows by right-clicking a row number and choosing “Hide,” then:
- Using
9will still include those hidden rows in the sum. - Using
109will exclude them.
If you are using Excel’s AutoFilter (the dropdown arrows on a header row), both codes ignore the filtered-out rows. So which one should you use? It depends on your intent:
- Use 1–11 when you want to ignore filtered rows but still include rows hidden manually (for example, if you hide detail rows to print a summary).
- Use 101–111 when you want to exclude any row that isn’t visible on screen, whether hidden by filter or manually.
In practice, most people use the 9/109 for SUM. A common tip is to use 109 if you want your total to match exactly what you see on screen.
Common Problems and Misconceptions
Problem: My SUBTOTAL returns 0 or an error. Check that the function number is valid (1–11 or 101–111). Also ensure the range references are correct and contain numeric values if you’re using SUM or AVERAGE.
Misconception: SUBTOTAL ignores all hidden rows. It only ignores rows hidden by filtering (with 1–11) or by manual hiding (with 101–111). It does not ignore rows hidden by grouping (outline) unless you manually hide them.
Problem: I want to count text cells but COUNT returns 0. Use function number 3 (COUNTA) instead of 2 (COUNT). COUNT only counts numbers; COUNTA counts any non-empty cell.
Misconception: SUBTOTAL can replace SUMIFS. No, SUBTOTAL is not conditional. It calculates over a whole range. For conditional sums, use SUMIFS. However, you can combine them: =SUBTOTAL(9, SUMIFS(...)) is not valid, but you can use an array formula or a helper column.
SUBTOTAL vs. AGGREGATE
Excel’s AGGREGATE function is a more powerful alternative to SUBTOTAL. It offers 19 functions (including LARGE, SMALL, MEDIAN, etc.) and options to ignore error values and nested subtotals. For example, to sum ignoring errors and hidden rows, you could use:
=AGGREGATE(9, 5, A2:A10)
Here, 9 is SUM and 5 means ignore hidden rows and error values. However, AGGREGATE requires Excel 2010 or later and is not available in older versions. SUBTOTAL is simpler and works in all versions.
Using SUBTOTAL in Tables and Filters
When you convert a range to an Excel Table (Ctrl+T), you can add a Total Row from the Table Design tab. The total row uses SUBTOTAL(109) by default, which sums only visible rows. This is why totals update when you filter a table.
If you want to change the total to AVERAGE, click the dropdown in the total row cell and select “Average.” Excel will automatically update the SUBTOTAL function number to 101.
Frequently Asked Questions
What does SUBTOTAL(9, A1:A10) mean? It means “sum the values in A1:A10, ignoring rows hidden by a filter.” The 9 is the function number for SUM.
Why does SUBTOTAL ignore hidden rows? Because it’s designed to work with filtered lists and outlines. It recalculates based on visible cells, which is useful for dynamic reports.
Can I use SUBTOTAL with multiple ranges? Yes, you can list up to 254 ranges as arguments, like =SUBTOTAL(9, A1:A5, C1:C5).
Does SUBTOTAL work in Google Sheets? Yes, Google Sheets has a SUBTOTAL function with the same syntax and function numbers.
How do I get a subtotal that ignores manually hidden rows? Use function numbers 101–111. For example, =SUBTOTAL(109, A1:A10) sums only visible rows, including those not hidden by a filter.
Is there a shortcut to insert SUBTOTAL? You can use the Subtotal command under Data > Outline > Subtotal, but that inserts subtotal rows into your data. For a single formula, just type it manually.
Related
- How to Update a Dictionary in Python
- Federal Bank Balance Sheet: Key Figures Explained
- Power Automate String to HTML: How to Convert & Format
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- VLOOKUP Match Two Columns: How To & FixesTo match two columns with VLOOKUP, use the formula =VLOOKUP(lookup_value, table_array, col_index_num, FALSE) where the lookup_value is a…
- Excel IFS vs COUNTIF: When to Use EachIn Excel, IFS tests conditions in order and returns a corresponding result, while COUNTIF counts cells that meet…
- Excel Formula for Matching Values: Exact Match GuideFor an exact match in a list, use =MATCH(E2,A2:A100,0): it returns the matching item’s position within the range,…
- Show Formulas in Excel: Steps for Windows, Mac, and WebTo show formulas instead of calculated results in Excel, open the Formulas tab and select Show Formulas in…
- Filter Excel Horizontally: Methods That WorkYes, you can filter Excel horizontally, but the standard Filter dropdown is designed to filter records in rows,…
- ISNUMBER Formula in Excel: Syntax and ExamplesThe ISNUMBER function in Excel checks whether a value is a number and returns TRUE if it is,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.