Totals and counts function

SUBTOTAL

Total what the filter left showing.

Purpose

Total what a filter has left showing

Returns

The result of the job you asked for, over the visible rows

Syntax

=SUBTOTAL(what_to_do, range1, [range2], ...)

ArgumentRequiredWhat goes here
what_to_doRequired9 adds up, 1 averages, 2 or 3 count, 4 takes the largest, 5 the smallest. Add 100 to leave hidden rows out.
range1RequiredThe block to work on, like F2:F30.
range2OptionalThe block to work on, like F2:F30.

How to use SUBTOTAL

SUBTOTAL takes a number saying what to do, then the range. 9 adds, 1 averages, 2 counts numbers, 3 counts anything, 4 is the largest and 5 the smallest.

What makes it worth learning is that it ignores rows a filter has hidden. Filter to one supplier and a SUBTOTAL underneath reports that supplier, while a SUM underneath goes on reporting the lot.

It also skips any other SUBTOTAL inside its range, so a grand total over a column of subtotals does not double count.

Codes over a hundred mean the same jobs and additionally skip rows hidden by hand. 9 and 109 behave identically under a filter and differ only when somebody has hidden a row themselves.

Examples

Every result below is worked out by the same evaluator that marks your answers, on the sheet shown here.

Payables ageing — October.xlsxSheet1
Harbour Foods payables at 31 October 2026, with supplier terms alongside
ABCDEFGH
1InvoiceSupplierStatusDays overdueAmountSupplierTerms (days)
2INV-8801Brightwell PaperOverdue12940Ashgrove Catering30
3INV-8802Calder UtilitiesQueried471180Brightwell Paper30
4INV-8803Meridian FreightOverdue632450Calder Utilities14
5INV-8804Ashgrove CateringOn terms0405Meridian Freight45
6INV-8805Brightwell PaperOverdue38760Thornbury Print60
7INV-8806Thornbury PrintOverdue911320
8INV-8807Meridian FreightOn terms0580
9INV-8808Calder UtilitiesOverdue24215
FormulaResult
=SUBTOTAL(9,E2:E9)The total with nothing filtered, which matches SUM exactly. The difference only shows once a filter is on.7850
=SUBTOTAL(3,A2:A9)Job 3 counts anything that is not empty, so it counts rows even though the column is text.8
=SUBTOTAL(1,E2:E9)Job 1 averages.981.25
=SUBTOTAL(4,E2:E9)-SUBTOTAL(5,E2:E9)Largest less smallest, both taken over whatever the filter is showing.2235

Notes

  • SUBTOTAL respects a filter. SUM does not. That is the entire reason to reach for it.
  • It skips other SUBTOTALs in its range, so nested totals do not double count.
Practise SUBTOTAL in Unit 16

A reference tells you what it does. A unit makes you use it.