# How to count duplicate rows based on two columns in Excel

Use COUNTIFS on both columns to see how often each pair occurs, and count the pairs that occur more than once: `=SUMPRODUCT(--(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1))`.

**Excel:** `=SUMPRODUCT(--(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1))` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D |
| --- | --- | --- | --- |
| Employee | Date |  | Duplicate rows |
| Lena | 2026-03-02 |  |  |
| Omar | 2026-03-02 |  |  |
| Lena | 2026-03-03 |  |  |
| Lena | 2026-03-02 |  |  |
| Noor | 2026-03-03 |  |  |
| Omar | 2026-03-04 |  |  |
| Noor | 2026-03-03 |  |  |
| Lena | 2026-03-04 |  |  |
| Omar | 2026-03-02 |  |  |
| Tom | 2026-03-04 |  |  |

Formula in E1: `=SUMPRODUCT(--(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1))`

Result: 6

## How it works

COUNTIFS with both columns as criteria returns, for each row, how many rows have the same employee **and** the same date. Rows with a count above 1 are duplicates. Lena on March 2, Noor on March 3 and Omar on March 2 were each entered twice: 6 rows.

Lena also appears on other dates, but those are different pairs and aren't duplicates.

## Other ways

- `=ROWS(A2:B11)-ROWS(UNIQUE(A2:B11))`: Counts the extra copies: the rows Remove Duplicates would delete. (Returns 3, one per duplicated pair.)

## Common mistakes

- Checking each column separately finds names or dates that repeat, which is normal. Duplicates are about the combination.
- Dates with different times are different values. If the column has timestamps, compare `INT` of the dates.

## Questions

**How do I flag each duplicate row?**

In a helper column: `=COUNTIFS($A$2:$A$11,A2,$B$2:$B$11,B2)>1`, filled down.

**How do I check three columns?**

Add a third pair to COUNTIFS: `,C2:C11,C2:C11`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/count-duplicate-rows-based-on-two-columns
