TheSUMIF functionand theSUMIFS functionare both good options for counting text values, and both functions supportwildcards.

However, neither function is case-sensitive, so they can’t be used to solve this problem.

A good solution is to use theEXACT functionwith theSUMPRODUCT function, as explained below.

Excel formula: Sum if cells contain specific text

EXACT function

The EXACT function has just one purpose: to compare text in a case-sensitive manner.

EXACT takes twoarguments:text1andtext2.Iftext1andtext2match exactly (considering upper and lower case), EXACT returns TRUE.

For convenience,code(B5:B15) andqty(C5:C15) arenamed ranges.

Excel formula: Sum if cells are equal to

Each FALSE represents a non-match.

In this case, the array operation is performed by the EXACT function in the previous step.

InExcel 365, you’ve got the option to replace SUMPRODUCT with theSUM function.

Excel formula: Count cells that contain case sensitive

To read more about this, seeWhy SUMPRODUCT?

Boolean operations in array formulas

Excel SUMPRODUCT function

Excel EXACT function

Article image