Excel SUM Function

The Excel SUM function returns the sum of all numbers in a specified range

Example: Excel SUM Function

Excel SUM Function

METHOD 1. Excel SUM Function

EXCEL

=SUM(C5:C11)
Result in cell E5 (3,792) - returns the sum of all the numbers in range (C5:C11).

=SUM(C5,C9)
Result in cell E6 (1,570) - returns the sum of cell C5 and C9 which are associated with Bread and Apples from the Product List.

METHOD 2. Excel SUM function using the Excel built-in function library

EXCEL

Formulas tab > Function Library group > Math & Trig > SUM > populate the input box

=SUM(C5:C11)
Note: in this example we are summing all of the numbers in range (C5:C11).
Built-in Excel SUM Function

METHOD 1. Excel SUM function using VBA

VBA

Sub Excel_SUM_Function()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("SUM")

'apply the Excel SUM function
ws.Range("E5") = Application.WorksheetFunction.Sum(ws.Range("C5:C11"))
ws.Range("E6") = Application.WorksheetFunction.Sum(ws.Range("C5"), ws.Range("C9"))

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named SUM.
Data Range: Ensure that the data you want sum is captured in range ("C5:C11") in the SUM worksheet.

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell references ("E5") and ("E6") in the VBA code to any cell in the worksheet, that doesn't conflict with formula.
Data Range: Select the range that you want to sum by changing the range ("C5:C11") to any range in the worksheet, that doesn't conflict with the formula.

Usage of the Excel SUM function and formula syntax

EXPLANATION

DESCRIPTION
The Excel SUM function returns the sum of all numbers in a specified range.
SYNTAX
=SUM(number1, [number2], ...)
ARGUMENTS
number1: (Required) The first numeric value to add. This can be a single cell or a range of cells.
number2: (Optional) The second numeric value to be add. This can be a single cell or a range of cells.

ADDITIONAL NOTES
Note 1: In Excel 2007 and later the SUM function can accept up to 255 value arguments. In Excel 2003 the SUM function can only accept up to 30 value arguments.
Note 2: If you are adding a date, the formula will use the date's numeric value.