Function Problems

Fix Excel COUNTIF Not Counting Names With Different Capitalization

Huma Ashraf ChHuma Ashraf Ch Nov 27, 2026 868 views

Question details

Determine why COUNTIF or COUNTIFS does not count all matching names and correct the source values.

Fix Excel COUNTIF Not Counting Names With Different Capitalization
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.
Before you start

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.

Solution 1Recommended

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.

1
Add a helper column

Insert a blank column next to the names. If the first name is in A2, enter =TRIM(CLEAN(SUBSTITUTE(A2,CHAR(160)," "))) in B2.

2
Fill the formula down

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.

3
Count the cleaned names

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.

4
Check other conditions

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 the names before counting them
Some hidden characters may remain: CLEAN removes common nonprinting characters, but it does not remove every Unicode character. If a name still does not match, inspect the source value for other unusual characters.
Count cleaned names in WPS Spreadsheet

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. 1. Open the spreadsheet: Open WPS Office, select Spreadsheet, and open the Excel file containing the names.
  2. 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. 3. Fill down: Select B2 and drag the fill handle down through the rows containing names.
  4. 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.
Count names without treating capitalization as a differenceClean common imported spaces and nonprinting characters with formulasOpen and edit Microsoft Excel XLSX and XLS filesWork in a familiar spreadsheet interface
microsoft office alternative - wps office

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.