How to Count Specific Names in Excel (3 Useful Methods)

Let’s say we have a dataset that depicts the employee ID, the Year, and the Sales Person of the Year. We’ll use the dataset (in B4:D14 cells) shown below to count occurrences of names.

Dataset 1


Method 1 – Using the COUNTIF Function to Count Exact Matches

  • We entered a name in the G4 cell.
  • The formula in the G5 cell will be:
=COUNTIF(D5:D14,G4)

The D5:D14 cells represent the Sales Person of the Year (range argument), and the G4 cell denotes Mathew Smith (criteria argument).

How to Count Specific Names in Excel Using COUNTIF Function

Formula Breakdown

  • The COUNTIF function matches the name from cell F4 in the lookup array (D5:D14) and returns the number of counts.

Method 2 – Applying a Wildcard Character to Count Specific Names


Case 2.1 – If Cell Contains Specific Name at the Start 

  • We put the first name in the search cell G4.
  • The formula in the G5 cell will be as follows.
=COUNTIF(D5:D14,G4&“*”)

How to Count Specific Names in Excel Using Wildcard Character


Case 2.2 – When the Name Is in the Middle

  • The formula for the G5 cell will be as follows.
=COUNTIF(D5:D14,“*”&G4&“*”)

How to Count Specific Names in Excel Using Wildcard Character


Case 2.3 – If the Name Is at the End

  • The formula for the G5 cell will be as follows.
=COUNTIF(D5:D14,“*”&G4)

How to Count Specific Names in Excel Using Wildcard Character


Method 3 – Utilizing the SUMPRODUCT Function to Count Specific Names in Excel

We have a table that shows the Employee ID, the Department they are employed in, and the Employee Name.

Dataset 2


Case 3.1 – Applying the SUMPRODUCT Function to Match for the Exact Name (Case-Sensitive)

  • Use the following formula:
=SUMPRODUCT(--EXACT(G4, D5:D14))

The G4 cell denotes Smith (text1 argument) and the D5:D14 cells represent the Employee Name (text2 argument).

How to Count Specific Names in Excel Using SUMPRODUCT Function

Formula Breakdown

  • The EXACT function compares two strings of text and returns true if they are an exact match. The double minus operator changes the TRUE and FALSE values to numeric values 1 and 0.
  • The SUMPRODUCT function returns the sum of all the 1’s in the corresponding range which represents the number of matches.

Case 3.2 – Using the SUMPRODUCT Function to Partially Match for a Name (Case-Sensitive)

  • Use the following formula:
=SUMPRODUCT(--(ISNUMBER(FIND(G4, D5:D14))))

The G4 cell denotes Smith (find_text argument) and the D5:D14 cells represent the Employee Name (within_text argument).

How to Count Specific Names in Excel Using SUMPRODUCT Function

Formula Breakdown

  • The FIND function gives the position (as numbers) of a text inside a string.
  • The ISNUMBER function handles these numbers returned by the FIND function, which is then converted to 1 or 0 via the — operator.
  • The SUMPRODUCT function adds up all the 1’s which represents the number of matches.

Case 3.3 – Using SUMPRODUCT Function to Count Names (Case-Insensitive)

  • Use the following formula:
=SUMPRODUCT(--(ISNUMBER(SEARCH(G4, D5:D14,))))

Using SUMPRODUCT Function

Formula Breakdown

  • The SEARCH function determines the location (as number) of a text inside a string.
  • The ISNUMBER function converts the numbers provided by the SEARCH function to ones and zeroes.
  • The SUMPRODUCT function returns the number of counts.

Things to Remember

  • The COUNTIF function returns integer output.
  • The COUNTIF function does not count the cells with non-numeric values, like text or #NA.
  • COUNTIF function is unable to count specific numbers within a number like “123” from “4546123”
  • For columns with a mixture of text and numbers, the COUNTIF function gives the wrong count.

Download the Practice Workbook


<< Go Back to Count Words | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Eshrak Kader
Eshrak Kader

Eshrak Kader is a dedicated professional with a BSc. Degree in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology. He boasts a rich background in Microsoft Office Suite, and over the past year, he has authored over 120 insightful articles for the ExcelDemy. Currently, Eshrak leads a team of 5 in the ExcelDemy Video project and enjoys problem-solving and making videos on Excel. Eshrak’s passion for continuous learning underscores his commitment to excellence in... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo