# SUMIF function

This article describes the formula syntax and usage of the **SUMIF** function (function: A prewritten formula that takes a value or values, performs an operation, and returns a value or values. Use functions to simplify and shorten formulas on a worksheet, especially those that perform lengthy or complex calculations.) in Microsoft Excel.

## Description

You use the **SUMIF** function to sum the values in a range (range: Two or more cells on a sheet. The cells in a range can be adjacent or nonadjacent.) that meet criteria that you specify. For example, suppose that in a column that contains numbers, you want to sum only the values that are larger than 5. You can use the following formula:

=SUMIF(B2:B25,">5")

In this example, the criteria is applied the same values that are being summed. If you want, you can apply the criteria to one range and sum the corresponding values in a different range. For example, the formula **=SUMIF(B2:B5, "John", C2:C5)** sums only the values in the range C2:C5, where the corresponding cells in the range B2:B5 equal "John."

** Note ** To sum cells based on multiple criteria, see SUMIFS function.

## Syntax

SUMIF(range, criteria, [sum_range])

The **SUMIF** function syntax has the following arguments (argument: A value that provides information to an action, an event, a method, a property, a function, or a procedure.):

**range**Required. The range of cells that you want evaluated by criteria. Cells in each range must be numbers or names, arrays, or references that contain numbers. Blank and text values are ignored.**criteria**Required. The criteria in the form of a number, expression, a cell reference, text, or a function that defines which cells will be added. For example, criteria can be expressed as 32, ">32", B5, 32, "32", "apples", or TODAY().

** Important ** Any text criteria or any criteria that includes logical or mathematical symbols must be enclosed in double quotation marks (**"**). If the criteria is numeric, double quotation marks are not required.

**sum_range**Optional. The actual cells to add, if you want to add cells other than those specified in the range argument. If theargument is omitted, Excel adds the cells that are specified in the*sum_range*argument (the same cells to which the criteria is applied).*range*

** Notes **

- You can use the wildcard characters — the question mark (
**?**) and asterisk (*****) — as theargument. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (*criteria***~**) preceding the character.

## Remarks

- The SUMIF function returns incorrect results when you use it to match strings longer than 255 characters to the string #VALUE!.
- The
argument does not have to be the same size and shape as the*sum_range*argument. The actual cells that are added are determined by using the upper leftmost cell in the*range*argument as the beginning cell, and then including cells that correspond in size and shape to the*sum_range*argument. For example:*range*

If range is |
And sum_range is |
Then the actual cells are |
---|---|---|

A1:A5 | B1:B5 | B1:B5 |

A1:A5 | B1:B3 | B1:B5 |

A1:B4 | C1:D4 | C1:D4 |

A1:B4 | C1:C2 | C1:D4 |

However, when the ** range** and

*sum_***arguments in the SUMIF function do not contain the same number of cells, worksheet recalculation may take longer than expected.**

*range*## Examples

### Example 1

The workbook below shows examples of this function. Inspect them, change existing formulas, or enter your own formulas to learn how the function works.

To work more in-depth with the example data in Excel, download the embedded workbook to your computer, and then open it in Excel.

### Example 2

The workbook below shows examples of this function. Inspect them, change existing formulas, or enter your own formulas to learn how the function works.

To work more in-depth with the example data in Excel, download the embedded workbook to your computer, and then open it in Excel.