Solving the Case-Sensitivity Issue with COUNTIF in Excel


Many people are familiar with using the COUNTIF function to count the number of occurrences that meet a specific condition. However, COUNTIF has a limitation: it cannot distinguish between uppercase and lowercase letters. When faced with certain scenarios, it may yield incorrect results. So, how can we modify the formula to obtain the correct answer?

Can COUNTIF Handle This?

The answer is no. COUNTIF cannot differentiate between uppercase and lowercase letters. For COUNTIF, "Abc," "ABC," and "aBc" are all considered the same. Therefore, if you apply COUNTIF to the ranges D2, D3, and D4, the result will be 6.

What Formula Can Replace COUNTIF?

The solution is to use the following formula:

=SUMPRODUCT(EXACT(C2,$A$2:$A$7)*1)

Formula Breakdown:

  • EXACT Function: This function can distinguish between uppercase and lowercase letters. For example, ="ABC"="Abc" will return FALSE.
  • EXACT(C2,$A$2:$A$7): This part instructs Excel to verify each cell in the range A2:A7 against C2, resulting in an array of TRUE and FALSE values, such as {TRUE;FALSE;FALSE;TRUE;TRUE;FALSE}.
  • *EXACT(C2,$A$2:$A$7)1: By multiplying the array of TRUE and FALSE values by 1, we convert it to numerical values, resulting in {1;0;0;1;1;0}.
  • SUMPRODUCT(EXACT(C2,$A$2:$A$7)*1): Finally, this sums up the resulting array, giving the count of how many times "Abc" appears in the range A2:A7, which would be 3 in this case.

Conclusion

By using the combination of the EXACT function and SUMPRODUCT, you can effectively count case-sensitive occurrences in Excel, overcoming the limitations of the COUNTIF function.

A0008


Comprehensive Technical Support Solutions

We provide a range of technical support solutions to meet your needs.
Explore our core services:

man and woman wearing headphones while working in the office

Get on-demand assistance with Microsoft Excel, Word and PowerPoint. Send your question via WhatsApp, and we will help you resolve it promptly.

serious diverse students looking at laptop

Join our Online Learning Group Facebook page. Explore more than 200 tutorials and a comprehensive library of instructional videos at your own pace.

woman in yellow blazer doing a presentation

Build your team’s skills with tailored corporate training programmes. Our courses are designed around your organisation’s needs and equip employees with practical, up-to-date tools.