## 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.*