# How to sum the digits of a number in Excel

Split the number into single characters and add them: `=SUMPRODUCT(--MID(A2,SEQUENCE(LEN(A2)),1))`.

**Excel:** `=SUMPRODUCT(--MID(A2,SEQUENCE(LEN(A2)),1))` (Excel 2021, 2024 and Microsoft 365)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Number | Digit sum |
| 4721 |  |
| 90385 |  |
| 1006 |  |
| 777 |  |
| 52814 |  |

Formula in B2, filled to B6: `=SUMPRODUCT(--MID(A2,SEQUENCE(LEN(A2)),1))`

Result: 14; 25; 7; 21; 20

## How it works

LEN counts the digits (4 for 4721), SEQUENCE lists the positions 1 to 4, and MID takes one character from each position: "4", "7", "2", "1". The double minus turns those characters into numbers and SUMPRODUCT adds them.

## Other ways

- `=SUM(--MID(A2,SEQUENCE(LEN(A2)),1))`: Excel 365 handles the array inside SUM directly.

## Common mistakes

- A minus sign or decimal point can't be turned into a number and gives #VALUE!. Use `ABS` and `SUBSTITUTE(A2,".","")` first.
- SEQUENCE needs Excel 2021 or 365. In older Excel use `ROW(INDIRECT("1:"&LEN(A2)))` for the positions.

## Questions

**How do I reduce it to a single digit?**

For a positive whole number, the repeated digit sum is `=1+MOD(A2-1,9)`.

**How do I sum the digits of a text code like "AB-4721"?**

Strip the non-digits first, or sum only numeric characters: `=SUMPRODUCT(IFERROR(--MID(A2,SEQUENCE(LEN(A2)),1),0))`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/sum-the-digits-of-a-number
