Fix Excel COUNTIF Not Counting Names With Different Capitalization
Question details
Determine why COUNTIF or COUNTIFS does not count all matching names and correct the source values.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Counting names that have different capitalization, including names copied from another table.
- Observed behavior
- Some names are missed even though COUNTIF and COUNTIFS normally match text without regard to capitalization.
Identify the name range and the cell containing the name to count. Check whether the formula also uses other criteria, since every COUNTIFS condition must match.
Clean the names before counting them
Use a helper column to remove common extra spaces and nonprinting characters from imported names.
COUNTIF and COUNTIFS are not case-sensitive. Leading, trailing, or repeated spaces and hidden characters can make otherwise similar names different.
Insert a blank column next to the names. If the first name is in A2, enter =TRIM(CLEAN(SUBSTITUTE(A2,CHAR(160)," "))) in B2.
Select B2 and drag its fill handle down alongside the name list. The formula replaces nonbreaking spaces, removes common nonprinting characters, and trims extra spaces.
If the name to find is in D2, enter =COUNTIF(B2:B100,TRIM(CLEAN(SUBSTITUTE(D2,CHAR(160)," ")))) in an empty cell. Adjust the range and cell references to match your sheet.
If you use COUNTIFS, replace the original name range with the cleaned helper range and check that the other criteria and ranges also match the intended rows.

Clean and count names in WPS Spreadsheet
Use a helper column in WPS Spreadsheet to clean common spaces and hidden characters, then count the normalized names with COUNTIF.
- 1. Open the spreadsheet: Open WPS Office, select Spreadsheet, and open the Excel file containing the names.
- 2. Clean the first name: In an empty helper column, enter =TRIM(CLEAN(SUBSTITUTE(A2,CHAR(160)," "))) in B2, replacing A2 with the first name cell if needed.
- 3. Fill down: Select B2 and drag the fill handle down through the rows containing names.
- 4. Count matching names: With the name to find in D2, enter =COUNTIF(B2:B100,TRIM(CLEAN(SUBSTITUTE(D2,CHAR(160)," ")))) in an empty cell. Adjust the references for your data.

Frequently Asked Questions
Does Excel COUNTIF distinguish between uppercase and lowercase names?
No. COUNTIF and COUNTIFS normally treat John Doe, John doe, and john doe as matches. Check for spaces or hidden characters if the count is lower than expected.
Can Text cell formatting make COUNTIFS miss a name?
Text formatting alone does not normally prevent identical names from matching. Check the actual cell contents and the other COUNTIFS criteria.
Why do copied names count differently from names I typed?
Copied names may contain extra spaces, nonbreaking spaces, or nonprinting characters. Use a helper column with TRIM, CLEAN, and SUBSTITUTE to normalize them before counting.
Will exporting the data to CSV remove all hidden characters?
Not necessarily. After importing or opening the CSV, check the names and use a cleaning formula if the count is still incorrect.




