ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Comparisons
  3. SUBTOTAL vs SUM in Excel: Totals That Respect Filters

SUBTOTAL vs SUM in Excel: Totals That Respect Filters

By ExcelReady Team·Updated November 1, 2026·7 min read

The short answer

SUM adds every number in a range, whether rows are filtered, hidden or already totals. SUBTOTAL with 9 adds only the rows a filter leaves visible and skips other SUBTOTAL formulas, so group totals aren't counted twice. SUBTOTAL with 109 also skips rows you hid by hand. Use SUM for fixed totals and SUBTOTAL for lists people filter.

Key takeaways

  • =SUBTOTAL(9,C2:C20) adds only visible rows after a filter; =SUM(C2:C20) adds all rows.
  • SUBTOTAL ignores other SUBTOTAL formulas in its range, so a grand total never double counts group totals.
  • Function number 9 ignores filtered rows; 109 also ignores rows hidden by hand.
  • SUBTOTAL can also count, average or find the max of visible rows, using other function numbers.
On this page+
  1. SUBTOTAL vs SUM at a glance
  2. How SUM works
  3. How SUBTOTAL works
  4. The same data with SUM and SUBTOTAL
  5. When to use SUM
  6. When to use SUBTOTAL
  7. Common mistakes with SUBTOTAL and SUM
  8. Our recommendation
  9. Practise it

The short answer to SUBTOTAL vs SUM: SUM adds every number in a range, while SUBTOTAL adds only the rows that are visible after a filter and skips other subtotals inside the range. On a plain list they give the same answer. The difference appears as soon as someone filters the data or adds group totals. This comparison is for anyone who builds reports that other people filter, or who has seen a grand total come out exactly double.

SUBTOTAL vs SUM at a glance#

SUM is simple and counts everything; SUBTOTAL is aware of filters, hidden rows and other subtotals.

FeatureSUMSUBTOTAL
Syntax=SUM(number1, [number2], ...)=SUBTOTAL(function_num, ref1, [ref2], ...)
Rows hidden by a filterIncludedExcluded
Rows hidden by handIncludedIncluded with 9, excluded with 109
Other SUBTOTAL formulas in the rangeIncluded (double counting)Excluded
Hidden columnsIncludedIncluded
Other calculationsAdding onlySum, count, average, max, min and more
Accepts single numbers like =SUM(5,10)YesNo, ranges only
Excel versionsAll versionsAll versions

How SUM works#

SUM adds every number you give it: ranges, single cells or typed numbers.

Excel formula
=SUM(C2:C7)
=SUM(C2:C7,E2:E7)
=SUM(C2,C5,100)

It ignores text and empty cells but includes everything else, even rows you can't see. That makes it predictable and fast, and it is the right choice for most fixed totals. The SUM function guide covers every form, and the article on the SUM function has more everyday examples, including totals that span several sheets.

How SUBTOTAL works#

SUBTOTAL takes a function number that says which calculation to do, then one or more ranges.

Excel formula
=SUBTOTAL(9,C2:C7)
=SUBTOTAL(109,C2:C7)

The most common function numbers are:

CalculationSkips filtered rowsAlso skips rows hidden by hand
AVERAGE1101
COUNT (numbers)2102
COUNTA (non-empty)3103
MAX4104
MIN5105
SUM9109

Every SUBTOTAL, whatever the number, skips rows hidden by a filter and ignores other SUBTOTAL formulas in its range. The SUBTOTAL function guide and the article on the SUBTOTAL function list all eleven calculations.

When SUM and SUBTOTAL both fail: errors#

Both functions stop at an error. If one cell in the range shows #N/A or #DIV/0!, =SUM(C2:C7) and =SUBTOTAL(9,C2:C7) both return that error. In Excel 2010 and later, AGGREGATE fixes this. It works like SUBTOTAL with an extra options argument:

Excel formula
=AGGREGATE(9,6,C2:C7)

Here 9 means sum and 6 means "ignore error values", so the formula adds every number and skips the broken cells. Option 7 ignores both hidden rows and errors. AGGREGATE is worth knowing for messy imported data, but SUBTOTAL remains the more common choice in reports because it is shorter and older files use it everywhere.

The same data with SUM and SUBTOTAL#

Here is a sales list with six rows, totalling 700:

ABC
1RegionRepSales
2NorthKofi100
3NorthMei150
4SouthRavi200
5SouthLena50
6EastAna120
7NorthTom80

Test 1: no filter#

=SUM(C2:C7) and =SUBTOTAL(9,C2:C7) both return 700. With nothing hidden, they are identical.

Test 2: filter to North#

Turn on a filter (Data > Filter, or Ctrl+Shift+L on Windows and ⌘⇧F on a Mac) and show only North. Rows 4, 5 and 6 disappear.

  • =SUM(C2:C7) still returns 700.
  • =SUBTOTAL(9,C2:C7) returns 330, the total of the three North rows on screen.

Anyone reading the filtered report would expect 330. The SUM total no longer matches what they see. The filter lesson shows how filters hide rows, and how to filter and sum builds a full filtered report.

Test 3: hide a row by hand#

Clear the filter, then right-click row 4 and choose Hide.

  • =SUBTOTAL(9,C2:C7) returns 700: 9 ignores filters, not manual hiding.
  • =SUBTOTAL(109,C2:C7) returns 500: 109 also skips the hidden row.

Test 4: group totals inside the range#

Now picture a report with a subtotal under each region, as in the exercise on this page: North rows of 100 and 150 with =SUBTOTAL(9,C2:C3) below them, and South rows of 200 and 50 with =SUBTOTAL(9,C5:C6) below them. A grand total of =SUM(C2:C7) returns 1,000, because it adds the four sales and both group totals. =SUBTOTAL(9,C2:C7) returns 500, the correct grand total, because it skips the other SUBTOTAL cells.

This is how Excel's own Data > Subtotal command works: it inserts SUBTOTAL formulas so the grand total stays correct.

When to use SUM#

Use SUM when the total should always include every row. It fits:

  • Fixed totals that must not change when someone filters, such as a budget total or an invoice total.
  • Adding single cells or typed numbers, such as =SUM(B2,D2,F2).
  • Totals across sheets, such as =SUM(Jan:Dec!C10). See summing across sheets.
  • Simple lists that no one will filter or group, where SUM is the shortest and clearest choice.

The SUM lesson practises these basics.

When to use SUBTOTAL#

Use SUBTOTAL when the total should follow what is on screen. It fits:

  • Lists people filter, such as a sales log where managers pick a region.
  • Reports with group totals and a grand total in the same column.
  • Counting visible rows, such as =SUBTOTAL(3,A2:A100) to show how many records match the filter.
  • Excel tables. The Total Row of a table uses SUBTOTAL with 109, so totals update with the filter automatically.
  • Hiding rows by hand for a quick what-if: use 109 so the total ignores them.

When you use AutoSum (Alt+= on Windows, ⌘⇧T on a Mac) directly below a filtered list, Excel inserts SUBTOTAL(9, ...) instead of SUM for you. The guide to summing visible cells only covers more methods.

Common mistakes with SUBTOTAL and SUM#

  1. Using SUM on a filtered report. The total shows all rows, not what the reader sees. Use SUBTOTAL.
  2. Double counting group totals. A SUM grand total over a column with subtotals adds them twice. Use SUBTOTAL for both the group totals and the grand total.
  3. Using 9 when you hide rows by hand. 9 only skips filtered rows. Use 109 to skip manually hidden rows too.
  4. Expecting SUBTOTAL to skip hidden columns. It works down columns only. Hidden columns in a horizontal total are still added.
  5. Mixing SUM and SUBTOTAL for group totals. If group totals use SUM, a SUBTOTAL grand total will include them, because it only skips other SUBTOTAL cells.
  6. Forgetting the function number. =SUBTOTAL(C2:C7) is not valid. The function number always comes first.

Our recommendation#

Use SUM for totals that should always include every row, and for adding individual cells. Use SUBTOTAL, usually with 109, for any list that people will filter or hide rows in, and for any column that mixes group totals with a grand total. If you aren't sure whether a report will be filtered, SUBTOTAL is the safer choice: it gives the same answer as SUM until a filter appears, then keeps matching the screen.

In short: SUM for fixed totals, SUBTOTAL for anything that gets filtered or grouped.

Practise it#

Try the exercise on this page: build a grand total that skips the group subtotals. Then practise filters in a live spreadsheet and review the SUM function lesson: you type each formula, and it checks your answer instantly.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Rows 4 and 7 already hold group subtotals. In C8, use SUBTOTAL with function number 9 to calculate the grand total of C2:C7 without counting the group totals twice.

fx
ABCD
1
Region
Rep
Sales
2
North
Kofi
100
3
North
Mei
150
4
North total
250
5
South
Ravi
200
6
South
Lena
50
7
South total
250
8
Grand total
9
10
11

Tip: SUBTOTAL needs the function number first (9 means sum), then the whole range, C2:C7. It skips the two subtotal cells by itself.

Practise this in a lesson

LessonFilter a tableTurn on filter buttons with Ctrl+Shift+L, filter by one or several values and by a number condition, total and count only the visible rows with SUBTOTAL, then clear the filters.LessonSUM and AutoSumAdd up a column of numbers with SUM, then let AutoSum write the formula for you.Function guideSUBTOTALTotal filtered lists and grouped data without double counting using SUBTOTAL. Function codes 9, 109 and more, plus a live exercise.Function guideSUMAdd up columns, rows and separate ranges with Excel's SUM function. Clear examples, common mistakes and a live practice exercise.

Frequently asked questions

What is the difference between SUBTOTAL and SUM in Excel?

+

SUM adds every number in the range. SUBTOTAL(9, range) adds only the rows that are visible after filtering and skips other SUBTOTAL formulas. On an unfiltered list with no group totals, they return the same result.

What is the difference between SUBTOTAL 9 and 109?

+

Both add visible rows after a filter. 9 still includes rows you hid by hand with Hide, while 109 leaves them out too.

Why does my SUM include filtered rows?

+

SUM always adds every cell in its range. To total only what the filter shows, use =SUBTOTAL(9, range) or =SUBTOTAL(109, range).

Does SUBTOTAL ignore hidden columns?

+

No. SUBTOTAL only skips hidden rows. If you total across a row and hide a column, the hidden value is still included.

How do I sum only visible cells in Excel?

+

Use =SUBTOTAL(109, range). It skips rows hidden by a filter and rows hidden by hand. AutoSum also inserts SUBTOTAL automatically when you use it below a filtered list.

Sources

  • SUBTOTAL function - Microsoft Support
  • AGGREGATE function - Microsoft Support
  • SUM function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. SUBTOTAL vs SUM at a glance
  2. How SUM works
  3. How SUBTOTAL works
  4. The same data with SUM and SUBTOTAL
  5. When to use SUM
  6. When to use SUBTOTAL
  7. Common mistakes with SUBTOTAL and SUM
  8. Our recommendation
  9. Practise it

Keep reading

Math· 5 min read

How to Sum Only Visible (Filtered) Cells in Excel

To sum only visible cells in Excel, use SUBTOTAL instead of SUM. =SUBTOTAL(9,C2:C8) adds only the rows left showing after you filter. =SUBTOTAL(109,C2:C8) also skips rows you hid by hand. SUM always adds every cell, hidden or not. AGGREGATE(9,5,C2:C8) does the same and can skip error values too.

Data tools· 5 min read

SUBTOTAL in Excel: Totals That Ignore Filtered Rows

SUBTOTAL calculates a total that skips rows hidden by a filter: =SUBTOTAL(109,D2:D11) adds only the visible amounts, while SUM adds every row. The first argument picks the calculation: 9 or 109 sums, 1 or 101 averages, 3 or 103 counts non-empty cells. The 100s also skip rows you hid by hand.

Math· 5 min read

The Excel SUM Function: A Beginner's Guide

The Excel SUM function adds numbers. Type =SUM( then the cells to add, then ), for example =SUM(B2:B5) to add B2 through B5. A colon makes a range, and a comma adds separate cells or ranges, like =SUM(B2,B4:B5). SUM skips text and empty cells, so it doesn't break on gaps.

More on comparisons

  • SUMIF vs COUNTIF: Totals vs Counts
  • SUMIF vs SUMIFS: What's the Difference?
  • SUMPRODUCT vs SUMIFS: Which Should You Use?
  • Text to Columns vs TEXTSPLIT in Excel
  • TEXT vs VALUE in Excel: Numbers to Text and Back
  • TODAY vs NOW in Excel
All comparisons articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free