# SUBTOTAL Function

> Calculate the sum, average, count, maximum and more of a list with SUBTOTAL in TX Sheet Control: function_num codes, nested subtotals and errors.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Function
- **Path:** TX Sheet Control > API Reference > Formula Functions > SUBTOTAL Function
- **254 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/subtotal/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/subtotal/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/subtotal/llms-full.txt

---

Return a subtotal of a list, such as a sum, average or count. `function_num` selects the calculation: 1 `AVERAGE`, 2 `COUNT`, 3 `COUNTA`, 4 `MAX`, 5 `MIN`, 6 `PRODUCT`, 7 `STDEV`, 8 `STDEVP`, 9 `SUM`, 10 `VAR` or 11 `VARP`; 101 to 111 select the same calculations. `ref1`, `ref2` and further references are the ranges to calculate. Cells that hold a SUBTOTAL formula themselves are skipped, so subtotals are not counted twice. Any other `function_num` returns `#VALUE!`.

### Syntax

```text
SUBTOTAL(function_num, ref1, ref2)
```

Category: Math. Minimum arguments: 2. Maximum arguments: 255.

Available for supported offline calculation.

### Examples

```text
=SUBTOTAL(9,A1:A5)
```

The formula adds the values of A1:A5.

Cell and range examples require appropriate input values in the referenced cells. Handle invalid arguments, formula errors and array and spill constraints.

### See Also

- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)
- [Custom Functions and Formula Data](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/custom-functions/llms-full.txt)

---

## Nearby

- **Previous:** [SUBSTITUTE Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/substitute/llms-full.txt)
- **Next:** [SUM Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/sum/llms-full.txt)
