The challenge in this case is that the state abbreviations areembeddedin a text string.

This means we need to construct criteria that performs a “contains” jot down match.

To solve this problem, you could use either the SUMIF function or the SUMIFS function with awildcard.

Excel formula: Sum if cells contain specific text

If you need a case-sensitive formula, you could use the SUMPRODUCT function with the FIND function.

All three approaches are explained below.

Note: this example pulls together a number of ideas, which makes it more advanced.

Excel formula: Sum if begins with

It also means that the formula will continue to work correctly if new data is added to the table.

Wildcards

Excel functions like SUMIF and SUMIFS support thewildcardcharacters “?”

The table below shows some possible wildcard configurations.

Excel formula: Sum if not blank

Note that wildcards are enclosed in double quotes ("") when they appear in criteria.

Also notice that cell references arenotenclosed in double quotes.

Instead, they areconcatenatedto wildcards.

Excel formula: Sum if cells are equal to

SUMIFS solution

One way to solve this problem is with theSUMIFS function.

This is important partly because the SUMIFS and SUMIF function arenotcase-sensitive.

Also notice that the cell reference E5 isnotenclosed in double quotes.

Excel formula: Sum if cells are not equal to

Instead, it isconcatenatedto wildcards on either side.

However, the criteria is identical to what we used in SUMIFS above.

Case-sensitive solution

As mentioned above, the SUMIF and SUMIFS functions arenotcase-sensitive.

Excel formula: Sum if x or y

error when not found.

These are the rows where the state is “CA”.

For a more detailed explanation of FIND + ISNUMBERsee this article.

Excel formula: Sum if multiple columns

Note: InExcel 365, you could replace SUMPRODUCT with theSUM function.

To read more about this, seeWhy SUMPRODUCT?

Criteria can be applied to dates, numbers, and text.

Excel SUMIF function

SUMPRODUCT Function

The Excel SUMPRODUCT function multipliesrangesorarraystogether and returns the sum of products.

When the text is not found, FIND returns a #VALUE error.

How to use the SUMIF function

How to use the SUMIFS function

Excel SUMIFS function

Excel SUMPRODUCT function

Excel FIND function

Excel ISNUMBER function

Article image

Article image