ok.com
Browse
Log in / Register

What is the SUBTOTAL Function in Excel and How Do You Use It?

12/04/2025

The SUBTOTAL function in Excel is a powerful tool for performing calculations like sums, averages, and counts on a range of cells, with the unique ability to ignore rows hidden by filters. Mastering its use can significantly enhance your data analysis efficiency, especially when working with large, dynamic datasets.

What is the SUBTOTAL Function in Excel?

The SUBTOTAL function is a versatile formula that allows you to apply different operations—such as SUM, AVERAGE, or COUNT—to a specified cell range. Its key advantage over standard functions is its behavior with filtered lists; it can be set to calculate only visible cells, automatically excluding any hidden rows. The function's syntax is =SUBTOTAL(function_num, ref1, [ref2], ...), where function_num is a code that determines the operation (e.g., 9 for SUM, 1 for AVERAGE), and ref1 is the primary cell range. This makes it indispensable for creating reports where data visibility changes frequently.

How Do You Write a SUBTOTAL Formula?

Writing a SUBTOTAL formula is a straightforward, three-step process that ensures accurate calculations on your data.

  1. Initiate the Formula: Click on the cell where you want the result and type =SUBTOTAL(.
  2. Select the Function Number: Enter a number from 1-11 or 101-111. The numbers 1-11 include manually hidden rows in calculations, while 101-111 ignore them. For example, using 109 instead of 9 ensures your SUM calculation adjusts when you apply a filter.
  3. Define the Cell Range: Select the cells you want to include in the calculation, close the parenthesis, and press Enter. A complete formula looks like this: =SUBTOTAL(109, B2:B100).

This process allows you to quickly apply and change calculations without rebuilding formulas from scratch.

What Functions Can You Use with SUBTOTAL?

The SUBTOTAL function can reference 11 primary operations, each with two codes for handling hidden rows. The table below outlines the full list of available functions:

Function Num (Includes Hidden Rows)Function Num (Ignores Hidden Rows)Operation
1101AVERAGE
2102COUNT (numbers only)
3103COUNTA (non-empty cells)
4104MAX
5105MIN
6106PRODUCT
7107STDEV (sample standard deviation)
8108STDEVP (population standard deviation)
9109SUM
10110VAR (sample variance)
11111VARP (population variance)

For instance, if you need to find the average of a filtered list, you would use 101 as your function number. This flexibility is central to the function's utility.

What are the Key Benefits of Using the SUBTOTAL Function?

Integrating the SUBTOTAL function into your workflow offers several distinct advantages for data management.

  • Dynamic Calculations with Filters: The most significant benefit is its interaction with Excel's filter tool. When you filter a list, SUBTOTAL (using codes 101-111) instantly recalculates to reflect only the visible data. This provides an accurate total without needing to create new formulas.
  • Efficient Function Comparison: You can easily compare different calculations on the same data set by simply changing the function number. This is useful for data validation, such as comparing COUNT and COUNTA to identify blank cells quickly.
  • Prevents Double-Counting in Summaries: When creating summary reports with nested subtotals, SUBTOTAL automatically ignores other SUBTOTAL results within its range. This prevents errors that can occur if you use the standard SUM function, which would double-count those values.
  • Simplifies Data Analysis: By consolidating multiple operations into one function type, SUBTOTAL streamlines your worksheets, making them easier to audit and maintain.

To leverage the SUBTOTAL function effectively, always use the 101-111 series when working with filters to ensure calculations update correctly. It is the optimal tool for creating interactive and accurate reports in Excel.

Cookie
Cookie Settings
Our Apps
Download
Download on the
APP Store
Download
Get it on
Google Play
© 2025 Servanan International Pte. Ltd.