Order is not important, the two colors can appear anywhere in the cell.

However, both colors must appear in the same cell.

This problem can be solved with theSUMIFS function, which is designed to sum numbers based on multiple criteria.

Excel formula: Sum if cells contain either x or y

The syntax for the SUMIFS function depends on the number of conditions needed.

Each separate condition will require arangeandcriteria.

This means both criteria will be applied to the same range, the text in B5:B16.

Excel formula: Sum if x or y

The asterisk (*) is awildcardavailable in the SUMIFS function which means “zero or more characters”.

We use a wildcard in this case to match “red” occurringanywherein the text.

Notice we are applying twodifferent criteriato thesame range, B5:B15.

Excel formula: Sum if cells contain specific text

In other words, both “red” and “blue” must exist in the text.

Note that SUMIFS isnotcase-sensitive.

Other combinations

The other color combinations in the worksheet shown use the same pattern.

Excel formula: Count cells that contain either x or y

How to use the SUMIFS function

Excel SUMIFS function

Article image