logo
search
Function Problems

How to Count Cells Containing H or S in Excel

Phi Hung VoPhi Hung Vo Oct 1, 2026 868 views

Question details

The user needs to count specific cells containing the text 'H' or 'S' while ignoring blanks or other characters.

How to Count Cells Containing H or S in Excel
Product
Excel
Device & OS
not provided
Scenario
Analyzing worksheet data that includes multiple specific text values, requiring a count of cells that match one of several given criteria.
Observed behavior
The user wants to evaluate a specific range of cells and return the total count of cells that exactly match either 'H' or 'S'.
Before you start

Identify the exact range of cells you want to evaluate and ensure there are no hidden trailing spaces in the cells containing 'H' or 'S', as extra spaces can prevent the formula from recognizing the text.

Solution 1Recommended

Use Multiple COUNTIF Functions

The most straightforward method is to use the COUNTIF function twice (once for each text criteria) and add the results together.

This method is simple to understand and works perfectly when you only have a few specific text values to count.

1
Select the destination cell

Click on the empty cell where you want the final count to be displayed.

2
Enter the additive COUNTIF formula

Type the formula =COUNTIF(A1:A10,"H")+COUNTIF(A1:A10,"S") into the formula bar. Replace A1:A10 with the actual range containing your data.

3
View the result

Press the Enter key. The cell will now display the total combined number of cells containing exactly 'H' or 'S'.

Use Multiple COUNTIF Functions
Case Insensitivity: The COUNTIF function is case-insensitive by default. It will automatically count both uppercase 'H'/'S' and lowercase 'h'/'s'.
Efficient Spreadsheet Alternative

Count Data Easily with WPS Spreadsheet

You can perform all advanced data counting tasks, including COUNTIF and array formulas, directly in WPS Spreadsheet. It offers a familiar interface and comprehensive function support for all your data analysis needs.

  1. 1. Open your file in WPS Spreadsheet: Launch WPS Office and open the spreadsheet document containing the data you want to count.
  2. 2. Apply the counting formula: Select a blank cell and input the exact same formula you use in Excel: =SUM(COUNTIF(A1:A10,{"H","S"})).
  3. 3. Press Enter to calculate: Hit Enter to instantly view the counted cells. WPS Spreadsheet seamlessly handles array constants and standard Excel functions.
Fully compatible with Microsoft Excel formulas like COUNTIF and SUMFree, lightweight, and fast spreadsheet softwareSupports advanced array formulas for complex data counting
microsoft office alternative - wps office

Frequently Asked Questions

Why is my COUNTIF formula returning 0?

This usually happens if the target cells contain hidden characters or trailing spaces. You can use the TRIM function in a helper column to clean your data first, or check if your selected cell range in the formula is correct.

Can I count more than two specific texts using this method?

Yes. With the array method, you can easily add more criteria inside the curly brackets. For example, to count H, S, and X, you would use =SUM(COUNTIF(A1:A10,{"H","S","X"})).

Are these counting formulas case-sensitive?

No, the COUNTIF function is not case-sensitive. It will count 'H' and 'h' as the same character. If you require strict case-sensitive counting, you must use a combination of the SUMPRODUCT and EXACT functions, such as =SUMPRODUCT(--(EXACT(A1:A10,"H"))).