AGGREGATE Function

Excel Functions › Math & Trig

Excel 2010+ Math & Trig

The Excel AGGREGATE function applies one of 19 operations to a range while optionally ignoring errors, hidden rows, and nested subtotals — a more powerful successor to SUBTOTAL.


Quick answer:
=AGGREGATE(9,5,B2:B10) SUMs B2:B10, ignoring hidden rows

Syntax

=AGGREGATE(function_num, options, ref1, [ref2], ...) or =AGGREGATE(function_num, options, array, [k])
ArgumentDescription
function_numRequired1-19, choosing the operation: 9 = SUM, 1 = AVERAGE, 4 = MAX, 14 = LARGE, 15 = SMALL, and more.
optionsRequired0-7, choosing what to ignore: e.g. 5 = hidden rows, 6 = error values, 7 = both hidden rows and errors.
ref1 / arrayRequiredThe range to aggregate. Reference functions (1-13) take ranges; array functions (14-19, like LARGE) take an array plus a k.
[ref2...] / [k]OptionalMore ranges, or the k argument for array functions such as LARGE/SMALL/PERCENTILE.

How to use it

AGGREGATE takes two control numbers: function_num (what to calculate) and options (what to ignore). It can do everything SUBTOTAL does, plus skip error values and run array functions like LARGE and SMALL.

=AGGREGATE(9, 5, B2:B10) // SUM, ignore hidden rows
=AGGREGATE(9, 6, B2:B10) // SUM, ignore error values
=AGGREGATE(14, 6, B2:B10, 1) // LARGEST value, ignoring errors

Function codes 1–13 work on ranges; codes 14–19 (LARGE, SMALL, PERCENTILE, QUARTILE, …) take an extra k argument. The standout feature is option 6, which lets a total survive a range that contains error cells.

Sum past errors: if a column has stray #DIV/0! cells, =AGGREGATE(9,6,range) totals the good numbers and ignores the errors — something plain SUM can't do.

Try it: interactive demo

Live demo

Pick a AGGREGATE example to see the formula and its result.

Result:

Practice workbook

📊
Download the free AGGREGATE practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

Frequently asked questions

How is AGGREGATE different from SUBTOTAL?
AGGREGATE offers more operations (19 vs 11), and crucially it can ignore error values and run array functions like LARGE, SMALL, and PERCENTILE — none of which SUBTOTAL can do.
What do the options numbers mean?
They set what to ignore: 0 nested subtotals/AGGREGATEs, 1 also hidden rows, 2 also errors, 3 both, 4 nothing, 5 hidden rows, 6 errors, 7 hidden rows and errors.
How do I get the kth largest value ignoring errors?
Use an array function code with a k: =AGGREGATE(14,6,range,1) returns the largest value while ignoring any error cells; change 1 to 2 for the second largest.
Which Excel versions have AGGREGATE?
AGGREGATE was introduced in Excel 2010 and is available in every version since, including Microsoft 365.

Master functions like this in one day

This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related functions: SUBTOTAL · SUM · LARGE · SMALL · SUMIF