To use the SUBTOTAL formula across multiple columns in Excel, you must apply the formula to each column individually or use a Table object to automatically generate totals for every numeric column. The SUBTOTAL function is unique because it can ignore rows that have been hidden by a filter, ensuring your totals update dynamically as you change your view. Unlike the standard SUM function, which adds everything in a range regardless of visibility, SUBTOTAL allows you to see the sum, average, or count of only the data currently visible on your screen.

What You'll Need

  • Microsoft Excel (any modern version including Office 365, Excel 2021, 2019, or 2016).
  • A dataset organized in a tabular format with clear column headers.
  • Numeric data in the columns you wish to total.
  • Filtered data or a plan to use the Filter tool (Data > Filter).

Step-by-Step

  1. Prepare Your Data Range: Ensure your data is organized with headers in the top row and no completely empty rows or columns within the dataset. This prevents Excel from breaking the range when you apply filters or formulas.
  2. Convert Your Data to a Table (Recommended): While you can use SUBTOTAL on a standard range, converting your data to an official Excel Table makes managing multiple columns much easier. Highlight your data range, go to the Insert tab, and click Table. Ensure the box "My table has headers" is checked and click OK.
  3. Enable the Total Row: Once your data is a Table, click anywhere inside the table to reveal the Table Design tab in the top ribbon. In the Table Style Options group, check the box for Total Row. Excel will automatically add a row at the bottom of your data.
  4. Configure Subtotals for Each Column: By default, Excel may only put a subtotal in the last column. To apply it to multiple columns:
    • Click on the cell in the Total Row under the first column you want to sum.
    • A drop-down arrow will appear next to the cell. Click the arrow and select Sum (or Average, Count, Max, Min depending on your needs).
    • Repeat this process for every other column that requires a total.
  5. Manual Formula Method (For Non-Tables): If you prefer not to use a Table, you must enter the formula manually at the bottom of each column. Click the cell below your data in the first column and type: =SUBTOTAL(9, B2:B100).
    • The number 9 tells Excel to perform a SUM.
    • The range B2:B100 is the specific data in that column.
  6. Drag the Formula Across: After entering the manual formula in the first column, hover your mouse over the bottom-right corner of the cell until the cursor becomes a small black cross (the fill handle). Click and drag this handle horizontally across to the right. Excel will automatically adjust the column references (e.g., B2:B100 becomes C2:C100), applying the subtotal to all selected columns.
  7. Test with Filters: To verify the formula is working, go to the Data tab and click Filter. Click the filter arrow in any header and uncheck a few items. You will notice that the totals in your subtotal row change instantly to reflect only the visible rows, whereas a standard SUM formula would remain unchanged.

Common Mistakes

One of the most frequent errors is using the wrong function number. Users often confuse the 1-11 range with the 101-111 range. Function 9 sums visible cells and cells hidden by a filter, but it includes cells that you have hidden manually (by right-clicking the row and selecting Hide). If you want to ignore both filtered-out rows and manually hidden rows, you must use function 109. Using 9 when you meant 109 leads to inflated totals that don't match what you see on the screen.

Another common mistake is placing the SUBTOTAL formula inside the range being summed. For example, if your data is in cells B2 through B10, and you place your formula in cell B11, but your range is B2:B11, you create a circular reference. This causes Excel to return a 0 or an error because the formula is trying to calculate itself. Always ensure the formula sits outside the range of the data it is totaling.

Many users also forget that SUBTOTAL only works on numeric data. If your columns contain numbers stored as text (often indicated by a small green triangle in the corner of the cell), the SUBTOTAL function will treat those cells as zeros. This results in a total that is lower than expected, even though the numbers appear to be there.

Tips

To make your subtotal row stand out, apply a distinct fill color and bold text. If you are using a Table, you can change the style of the Total Row via the Table Design tab to ensure it is visually separated from the data entries.

If you have a massive dataset with hundreds of columns, avoid dragging the fill handle. Instead, copy the first SUBTOTAL cell (Ctrl+C), hold Ctrl and click all the other target cells in the Total Row, and then paste (Ctrl+V). This is significantly faster than dragging across a wide screen.

Consider using the AGGREGATE function if you have errors (like #DIV/0! or #N/A) in your data. While SUBTOTAL is great for filters, it will return an error if any cell in the range contains an error. The AGGREGATE function (specifically function 9 with option 6) can sum the range while ignoring both hidden rows and error values, making your spreadsheet much more robust.

Troubleshooting

If your SUBTOTAL formula is returning 0 despite there being numbers in the column, first check the data type. Highlight the column and look at the format dropdown in the Home tab. If it says "Text," change it to "Number." You may need to double-click into the cells or use the "Text to Columns" feature under the Data tab to force Excel to recognize the numbers.

If the total does not change when you filter the data, check if you accidentally used the SUM function instead of SUBTOTAL. A SUM formula looks like =SUM(B2:B10) and will never change based on filters. Replace it with =SUBTOTAL(9, B2:B10).

If you see a "Circular Reference" warning at the bottom of your Excel window, your formula range is too wide. Check the cell coordinates in your formula. If your formula is in cell B50, ensure the range ends at B49. To fix this, edit the formula and adjust the end-row number to be one row above the formula cell.

If the formula is returning an error like #VALUE!, look for non-numeric characters within your range. While SUBTOTAL usually ignores text, certain types of errors within the cells themselves will break the formula. Use the Filter tool to search for cells containing errors and correct them manually.

Frequently Asked Questions

Can I use SUBTOTAL for counting instead of summing?

Yes. Instead of using the number 9 (Sum), use the number 2 (Count) or 3 (CountA). Function 2 counts cells containing numbers, while 3 counts any cell that is not empty.

What is the difference between function 9 and function 109?

Function 9 ignores rows hidden by a filter but includes rows you hid manually. Function 109 ignores both filtered-out rows and manually hidden rows.

Does SUBTOTAL work with Pivot Tables?

No, Pivot Tables have their own built-in totaling and subtotaling mechanisms. You should use the "Subtotals" option within the PivotTable Analyze tab rather than writing a SUBTOTAL formula manually.

Can I use SUBTOTAL across different worksheets?

Yes, but it is complex. You can reference another sheet in the range (e.g., =SUBTOTAL(9, Sheet2!B2:B100)), but the formula will only respond to filters applied on that specific source sheet, not the sheet where the formula resides.

Will SUBTOTAL slow down my workbook?

In most cases, no. However, if you have tens of thousands of SUBTOTAL formulas across hundreds of columns, you may notice a slight lag during recalculation. Converting your data to a Table is the most efficient way to handle this.