Knowledge base / Excel

SUM in Excel: ranges, text, errors and visible rows

Five synthetic entries illustrate ordinary addition, overlapping ranges and numbers stored as text. I explain error handling and hidden rows separately.

Kajo RudzińskiPublished Updated 5 min read

Three channels of blocks converge into one collection tray.

SUM adds numbers from the cells or ranges supplied to it. I begin by asking what the range actually contains: numbers, text, an error, or perhaps a previously calculated total. Correct syntax cannot protect a result from including the same value twice.

I will use a small synthetic example to separate ordinary addition from ignoring errors and summing visible rows. Each need has its own rule. Establish that rule before choosing the formula.

Name, syntax and settings

The function is called SUM in English Excel and SUMA in Polish. Microsoft documents adding values, references and ranges. The page covers Microsoft 365 and Excel 2016, 2019, 2021 and 2024, among other editions.

=SUM(number1,[number2],...)
=SUM(B2:B6)

Square brackets in a syntax description indicate an optional argument. Do not enter them in the actual formula. I use commas for the English examples here. Function language and argument separators are separate matters: regional configuration affects the separator, so your environment may differ.

One small table

Place headers in A1:B1 and the following records in rows 2-6. These are unit quantities for five fictional entries. The negative value represents an adjustment.

Row A: Entry B: Units
2 First 10
3 Second 20
4 Adjustment -5
5 Fourth 0
6 Fifth 15

Put the formula outside B2:B6, for example in D2:

=SUM(B2:B6)

The result is 40. Follow the records: 10 and 20 make 30, the adjustment reduces that to 25, zero leaves it unchanged, and 15 produces 40. The function does not assess whether the adjustment is justified in business terms. It adds the number with its sign.

Several ranges and overlapping references

I can split the same data into two ranges:

=SUM(B2:B3,B4:B6)

The result remains 40 because the ranges together cover exactly the same five entries. However, =SUM(B2:B4,B4:B6) includes B4 twice. The result becomes 35 because the adjustment of -5 participates again.

This is not a deduplication mechanism. When using several arguments, I check their boundaries. A similar problem occurs when a range contains both detail records and a separate row totalling those records. The formula then adds a total to its own components. Correct arithmetic can still answer the wrong question if the selection is wrong.

Blank cells and numbers stored as text

In a separate trial, replace B3 with the text 20, entered using a leading apostrophe: '20. The apostrophe makes the entry text, even though it may look numeric. SUM referencing that range ignores the value. The result is 20, from the remaining numbers 10, -5, 0 and 15.

Microsoft explains that text in a range is ignored. A blank cell contributes no number either. However, a missing entry may matter to data completeness. I do not turn an unknown quantity into a business claim that the quantity was zero.

Restore the numeric 20 in B3 afterwards. Applying a number format alone does not establish that text has been converted into a number. When importing data, I check the actual content type and conversion method before treating a total as complete.

Channels carry blocks into a shared tray, while an empty track remains separate.

An error requires a decision

When a referenced cell contains an error instead of a number, ordinary SUM does not automatically become the sum of all the remaining valid entries. First establish why the error exists. Ignoring it can be an explicit reporting rule, but it should not be an accidental consequence of trying to hide a problem.

If the rule deliberately permits ignoring errors, AGGREGATE provides an option:

=AGGREGATE(9,6,B2:B6)

Function number 9 selects summation, and option 6 ignores error values. This is a separate function and a separate choice about the result’s scope. I would not use an arbitrary condition such as greater than -999999 as a substitute for an error-handling rule. That condition would also exclude legitimate values below the threshold.

Visible rows answer a different question

Ordinary SUM includes values in hidden and filtered-out rows. If you want to sum visible rows after filtering and also exclude manually hidden rows, consider SUBTOTAL:

=SUBTOTAL(109,B2:B6)

Here 109 selects summation while excluding manually hidden rows; filtered-out rows are excluded as well. This differs from a value-based condition such as a region or numeric threshold. Use SUMIF for one criterion and SUMIFS for multiple simultaneous criteria.

Check the boundaries before handing over the result

Restore the numbers from the table. The total should be 40. Clear B6 and it becomes 25. Explain whether clearing the cell means the entry no longer exists or its quantity is unknown. The formula cannot decide that distinction for you.

Add a number in B7 and check whether your formula includes it. The reference B2:B6 identifies a particular range; placing another value below it is not itself a declaration that the value is included. Before sharing a total, I check the boundaries, content types, errors and unit of measurement. Only then can I explain what the total represents.

Key takeaways

Does SUM ignore numbers stored as text?

Yes, when they are text in cells within a referenced range. A numeric-looking value may therefore be absent from the result; check its type and conversion.

Does SUM include only visible rows?

No. It includes hidden and filtered-out rows. For a vertical range excluding both groups, use SUBTOTAL with function number 109.

Does SUM automatically ignore errors?

No. Establish the cause first. If reporting rules permit ignoring errors, AGGREGATE with function number 9 and option 6 provides that behaviour.

AI was used in an automated way while working on this article. If you want to learn how to do it too, check out this project.

Kajo Rudziński

Newsletter KajoData

Let’s keep in touch.

I write about data analysis, learning and changing careers. My newsletter and the sign-up form are in Polish. If that works for you, I’d be glad to see you there.