Exceljet

Quick, clean, and to the point

Sum visible rows in a filtered list

Excel formula: Sum visible rows in a filtered list
Generic formula 
=SUBTOTAL(9,range)
Summary 

To sum values in visible rows in a filtered list (i.e. exclude rows that are "filtered out"), use the SUBTOTAL function.  In the example shown, the formula in F4 is:

=SUBTOTAL(9,F7:F16)

The result is $9.54, the subtotal of the visible values in column F.

Explanation 

In this example, the goal is to sum values in rows that are visible and ignore values in rows that are hidden. This is a job for the SUBTOTAL function. SUBTOTAL can perform a variety of calculations like COUNT, SUM, MAX, MIN, and more. What makes SUBTOTAL especially useful is that it automatically ignores rows that are hidden in a filtered list or table. This makes SUBTOTAL ideal for running calculations on the rows that are visible in filtered data.

Sum with SUBTOTAL

In the worksheet shown above, the goal is to sum the values in column F that are visible. The formula in F4 is:

=SUBTOTAL(9,F7:F16)

The first argument, function_num, specifies sum as the operation to be performed. SUBTOTAL automatically ignores the 3 rows hidden by the filter and returns $9.54, the subtotal of the visible values in column F.

Note that SUBTOTAL always ignores values in rows that are hidden with a filter. If you are hiding rows manually (i.e. right-click > Hide), use this version of the formula instead:

=SUBTOTAL(109,B7:B16)

Using 109 for the function number tells SUBTOTAL to ignore values in manually hidden rows in addition to those hidden with a filter. To be clear, values in rows that have been hidden with a filter are never included, regardless of function_num.

By changing the function number, the SUBTOTAL function can perform many other calculations. See the full list of available function numbers on this page.

Author 
Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.