In this example, the goal is to sum the Price in column C when the Product in column B begins with "sha". To solve this problem, you can use either the SUMIF function or the SUMIFS function with the asterisk (*) wildcard, as explained below.
Certain Excel functions like SUMIF and SUMIFS support the wildcard characters "?" (any one character) and "*" (zero or more characters), which can be used in criteria. These wildcards allow you to create criteria such as "begins with", "ends with", "contains 3 characters", etc. as shown in the table below:
|Cells with 3 characters||"???"|
|Cells like "bed", "bad", "bid", etc||"b?d"|
|Cells that begin with "xyz"||"xyz*"|
|Cells that end with "xyz"||"*xyz"|
Note that wildcards are enclosed in double quotes ("") when they appear in criteria.
The generic syntax for the SUMIF function looks like this:
In this example, the formula to sum Price when Product begins with "sha" is:
The criteria "sha*" means cells that begin with "sha". Notice you must enclose the text and the wildcard in double quotes (""). Also note that SUMIF is not case-sensitive. The criteria "sha*" will match "Shampoo", or "SHAMPOO".
You can also use the SUMIFS function to sum if cells begin with. SUMIFS can handle multiple criteria, and the order of the arguments is different from SUMIF. The generic syntax for a single condition looks like this:
Notice that the sum range always comes first in the SUMIFS function. The equivalent SUMIFS formula for this example is:
The criteria used with SUMIFS is the same as that used in SUMIF, with the text and wildcard are both enclosed in double quotes (""). Like SUMIF, the SUMIFS function is not case-sensitive.