ZetCode

Excel SUM Function

last modified April 4, 2025

The SUM function is one of the most fundamental and frequently used functions in Excel. It adds all numbers in a range of cells or individual values. This tutorial provides a comprehensive guide to using the SUM function with detailed examples. You'll learn basic syntax, practical applications, and advanced techniques to master this essential Excel function.

SUM Function Basics

The SUM function adds values together. It can handle individual numbers, cell references, ranges, or a mix of all three. The syntax is simple and flexible.

Component Description
Function Name SUM
Syntax =SUM(number1, [number2], ...)
Arguments 1-255 items to sum
Return Value Sum of all arguments

This table breaks down the essential components of the SUM function. It shows the function name, basic syntax format, argument limits, and return value characteristics.

Basic SUM Example

This example demonstrates the simplest use of the SUM function with individual numbers.

Basic SUM formula
=SUM(5, 10, 15)

This formula adds three numbers directly: 5, 10, and 15. The result will be 30. This shows how SUM can work with hard-coded values without cell references.

SUM with Cell References

A more practical use of SUM involves adding values from specific cells. Here's an example with cell references.

A B
10
20
30
=SUM(A1:A3)

The table shows a simple spreadsheet with values in column A and a SUM formula in cell B4 that adds up the values from A1 to A3.

SUM with cell range
=SUM(A1:A3)

This formula sums values in cells A1 through A3. The result will be 60 (10+20+30). Using ranges makes SUM more powerful for working with data in spreadsheets.

SUM with Multiple Ranges

SUM can handle multiple ranges or combinations of ranges and individual cells. This example shows this flexibility.

A B C
5 10
15 20
=SUM(A1:B2, 25)

This table demonstrates SUM's ability to combine different types of arguments. It shows values in cells A1 through B2 plus an additional number 25 being summed in cell C3.

SUM with multiple ranges
=SUM(A1:B2, 25)

This formula sums all values in range A1:B2 (5+10+15+20) plus an additional 25. The result will be 75. This demonstrates SUM's ability to combine different types of arguments.

SUM with Non-Adjacent Cells

You can sum non-adjacent cells by listing them individually or using the Ctrl key to select multiple cells while creating the formula.

A B C
10 20
30 40
=SUM(A1, B2, A3)

The table illustrates how to sum specific, non-adjacent cells (A1, B2, and A3) while ignoring other values in the range. Cell A3 is empty in this example.

SUM with non-adjacent cells
=SUM(A1, B2, A3)

This formula sums only specific cells: A1 (10), B2 (40), and A3 (empty, treated as 0). The result will be 50. This technique is useful when you need to sum scattered cells meeting certain criteria.

SUM with Text and Numbers

SUM automatically ignores text values in referenced cells. This example shows how SUM handles mixed content.

A B
10
Text
20
=SUM(A1:A3)

This table shows how SUM behaves when a range contains both numbers and text. The text value in A2 is ignored in the calculation, demonstrating SUM's handling of mixed data types.

SUM with text values
=SUM(A1:A3)

The formula sums A1 (10) and A3 (20), ignoring A2 ("Text"). The result is 30. This behavior makes SUM robust when working with datasets containing mixed content.

SUM with Blank Cells

SUM treats blank cells as zero in calculations. This example demonstrates this behavior.

A B
15
25
=SUM(A1:A3)

The table contains numbers and blank cells to demonstrate how SUM handles empty cells. The blank cell A2 is treated as zero in the calculation.

SUM with blank cells
=SUM(A1:A3)

The formula sums A1 (15) and A3 (25), treating blank A2 as 0. The result is 40. This automatic handling of blanks makes SUM convenient for incomplete datasets.

SUM Across Worksheets

SUM can reference cells across multiple worksheets. This example shows how to sum the same cell from different sheets.

3D SUM formula
=SUM(Sheet1:Sheet3!A1)

This formula sums cell A1 from Sheet1, Sheet2, and Sheet3. If A1 contains 10, 20, and 30 respectively, the result is 60. This 3D reference capability is powerful for consolidating data.

SUM with Logical Values

SUM treats TRUE as 1 and FALSE as 0 when logical values are included in the range. This example demonstrates this behavior.

A B
10
TRUE
FALSE
=SUM(A1:A3)

The table shows how SUM handles logical values (TRUE/FALSE) mixed with numbers. TRUE is converted to 1 and FALSE to 0 in the calculation.

SUM with logical values
=SUM(A1:A3)

This formula sums A1 (10), A2 (TRUE as 1), and A3 (FALSE as 0). The result is 11. This automatic conversion is helpful when working with conditional data.

SUM with Error Values

If any cell in the SUM range contains an error value, the entire SUM formula returns that error. This example shows this behavior.

A B
10
#N/A
20
=SUM(A1:A3)

The table demonstrates how SUM reacts when encountering error values in the range. The presence of #N/A in A2 causes the entire SUM to fail.

SUM with error values
=SUM(A1:A3)

This formula attempts to sum A1 (10), A2 (#N/A error), and A3 (20). Instead of a numeric result, it returns #N/A. You'll need to handle errors separately to sum valid numbers.

SUM with Named Ranges

SUM works seamlessly with named ranges, making formulas more readable. This example shows SUM with a named range.

A B
100
200
300
=SUM(Quarter1)

The table assumes cells A1:A3 are named "Quarter1". The SUM formula references this named range instead of cell addresses, improving formula clarity.

SUM with named range
=SUM(Quarter1)

This formula sums all values in the named range "Quarter1" (A1:A3). The result is 600. Named ranges make formulas more understandable and maintainable.

SUM with Dynamic Arrays

In modern Excel versions, SUM can work with dynamic array formulas. This example demonstrates summing a filtered range.

SUM with FILTER function
=SUM(FILTER(A1:A10, B1:B10="Yes"))

This formula sums only values in A1:A10 where corresponding cells in B1:B10 contain "Yes". The FILTER function creates a dynamic array that SUM then processes. This powerful combination enables conditional summing without needing SUMIF.

The SUM function is essential for all Excel users. From basic addition to complex multi-sheet calculations, SUM handles it all efficiently. Mastering its various applications will significantly improve your spreadsheet skills. Remember that SUM ignores text and treats blanks as zero, making it robust for real-world data.

Author

My name is Jan Bodnar, and I am a passionate programmer with extensive programming experience. I have been writing programming articles since 2007. To date, I have authored over 1,400 articles and 8 e-books. I possess more than ten years of experience in teaching programming.

List all Excel Formulas.