Function Problems

How to Use COUNTIFS to Count Data by First and Last Name in Excel

Rana GarciaRana Garcia Oct 29, 2026 870 views

Question details

The user needs to accurately count records associated with specific staff members by matching both their first and last names using a formula.

How to Use COUNTIFS to Count Data by First and Last Name in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Tracking staff records where multiple employees might share the same last name, requiring a dual-criteria match to ensure correct counts.
Observed behavior
Standard PivotTables may omit staff members who have no matching records. The user requires a formula-based method to display counts for everyone on the roster, including those with zero records.
Before you start

Ensure your dataset has separate columns for first names and last names without leading or trailing spaces, as extra spaces can cause the COUNTIFS function to incorrectly return zero.

Solution 1Recommended

Use COUNTIFS with Standard Cell Ranges

The standard COUNTIFS formula evaluates multiple criteria ranges simultaneously to ensure both first and last names match exactly before counting.

By utilizing absolute references (using the dollar sign $) for the search ranges, you can safely copy the formula down your roster without the reference shifting.

1
Select the target cell

Click the cell next to the first staff member's name on your roster where you want the total count to appear.

2
Enter the COUNTIFS formula

Type =COUNTIFS(Tests!$A$2:$A$100, A2, Tests!$B$2:$B$100, B2). In this example, 'Tests!$A$2:$A$100' is the First Name range in your source sheet, 'A2' is the first name on your roster, 'Tests!$B$2:$B$100' is the Last Name range, and 'B2' is the last name on your roster.

3
Apply formula to the rest of the list

Press Enter to get the result. Click the bottom-right corner of the cell and drag the fill handle down to apply the formula to the rest of the staff members.

Use COUNTIFS with Standard Cell Ranges
Adjusting Ranges: Make sure to adjust the sheet name ('Tests') and cell ranges to match your actual workbook structure.

Easily Manage and Count Data with WPS Spreadsheet

WPS Spreadsheet is a powerful, free alternative to Microsoft Excel that fully supports complex functions like COUNTIFS. You can seamlessly count, analyze, and manage datasets with matching criteria without worrying about formula compatibility.

  1. 1. Download and install: Download WPS Office for free from the official website and install it on your device.
  2. 2. Open your workbook: Launch WPS Spreadsheet and open your existing Excel workbook (.xlsx) containing the staff roster.
  3. 3. Apply COUNTIFS: Use the formula builder or type =COUNTIFS() directly into the cell to analyze your multi-criteria data exactly as you would in Excel.
Fully compatible with Microsoft Excel formulas and .xlsx files.Supports structured references for dynamic tables and arrays.Lightweight and fast, easily processing large datasets without lag.Free to use with a familiar, easy-to-navigate interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my COUNTIFS formula return 0 even when names visually match?

This is usually caused by hidden spaces, such as leading or trailing spaces, in either your source data or your criteria cells. You can use the TRIM() function to clean your text data before running the COUNTIFS formula.

Can I use wildcards with COUNTIFS for partial name matches?

Yes, COUNTIFS supports wildcards like the asterisk (*) for multiple characters or the question mark (?) for a single character. For example, typing "*Smith" as a criterion will count any name ending in Smith.

How is using COUNTIFS better than using a PivotTable for this task?

A standard PivotTable typically only displays items that exist in the source data. If a staff member has zero ordered tests, they will not appear in the PivotTable at all. Using a fixed roster alongside COUNTIFS ensures everyone is listed, returning a clear '0' for those with no records.