top of page

You are learning SUM in MS Excel

SUM with hidden rows or columns?

Absolutely! When it comes to summing data with hidden rows or columns in Excel, two main functions come into play: SUBTOTAL and AGGREGATE. Both offer distinct advantages depending on your specific needs.

SUBTOTAL - Simple Control Over Hidden Rows

The SUBTOTAL function provides a straightforward way to handle hidden rows caused by manual hiding (e.g., using the "Hide" option under the Home tab). Its syntax is:

`=SUBTOTAL(function_num, ref1, [ref2],...)`

Here's where the magic happens:

- function_num: This argument specifies the calculation you want to perform. Enter 109 for SUM to get the total while ignoring manually hidden rows.
- ref1: This is the main cell range you want to sum.
- [ref2],...: These are optional additional ranges to include in the summation.

For instance, if your data is in A1:A20 and you want to sum it excluding manually hidden rows, you can use the formula:

`=SUBTOTAL(109, A1:A20)`

AGGREGATE - Flexibility for Various Hidden Elements

AGGREGATE offers a more comprehensive approach, allowing you to control how different types of hidden elements are treated in your calculations. Its syntax is:

`=AGGREGATE(function_num, option_flags, ref1, [ref2],...)`

Here's a breakdown of the key components:

- function_num: Similar to SUBTOTAL, enter 9 here for the SUM function.
- option_flags: This argument provides granular control. Use 1048576 to disregard hidden rows caused by filters (AutoFilter functionality). You can combine multiple options using bitwise OR.
- ref1: The main cell range you want to sum.
- [ref2],...: Optional, additional ranges to include in the summation.

Let's say you want to sum data in B2:B15, but some rows might be hidden by filters and others manually hidden. You can use the formula:

`=AGGREGATE(9, 1048576, B2:B15)`

This formula ensures that both filtered and manually hidden rows are excluded from the summation.

Choosing the Right Tool

- If you only need to deal with manually hidden rows and prefer a simpler formula, SUBTOTAL is a great choice.
- If you require more control over hidden elements (filters or manual hiding) or want to perform calculations beyond SUM, AGGREGATE offers the necessary flexibility.

By understanding these functions and their functionalities, you can ensure your Excel formulas accurately calculate sums regardless of hidden rows or columns.

bottom of page