How to count duplicate rows based on two columns in Excel
Formula (Excel and Google Sheets)
=SUMPRODUCT(--(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1))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)).
- Result on the example
- 6 in
E1 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in E1. Change any input and the result updates, or edit the formula to experiment.
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.
=SUMPRODUCT(--(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1))Result6
A2:A1110 rows × 1 col: "Lena", "Omar", "Lena", "Lena", …A range: 10 cells in one column.
B2:B1110 rows × 1 col: 3/2/2026, 3/2/2026, 3/3/2026, 3/2/2026, …A range: 10 cells in one column.
COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11){10 rows × 1 col} 2, 2, 1, 2, …COUNTIFS: Counts rows that meet every condition.- criteria_range1
A2:A1110 rows × 1 col: "Lena", "Omar", "Lena", "Lena", … - criteria1
A2:A1110 rows × 1 col: "Lena", "Omar", "Lena", "Lena", … - criteria_range2
B2:B1110 rows × 1 col: 3/2/2026, 3/2/2026, 3/3/2026, 3/2/2026, … - criteria2
B2:B1110 rows × 1 col: 3/2/2026, 3/2/2026, 3/3/2026, 3/2/2026, …
- criteria_range1
COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1{10 rows × 1 col} TRUE, TRUE, FALSE, TRUE, …The > operator tests greater than.
-(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1{10 rows × 1 col} -1, -1, 0, -1, …Makes the value negative.
--(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1{10 rows × 1 col} 1, 1, 0, 1, …Makes the value negative.
SUMPRODUCT(--(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1))6SUMPRODUCT: Multiplies arrays row by row and adds the results.- array1
--(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1{10 rows × 1 col} 1, 1, 0, 1, …
- array1
In Google Sheets
The same formula works in Google Sheets: =SUMPRODUCT(--(COUNTIFS(A2:A11,A2:A11,B2:B11,B2:B11)>1)). We ran it in Google Sheets mode on the same data and it returns 6.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =ROWS(A2:B11)-ROWS(UNIQUE(A2:B11)) | 3Different result | 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
INTof the dates.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Count duplicate rows based on two columns
E1, count the timesheet rows whose employee-and-date pair appears more than once.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.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.