To stop someone typing the same ID or email twice, add a Data Validation rule with a COUNTIF formula. Excel rejects the entry the moment it would create a duplicate — cleaner than hunting for dupes after the fact.
≤ 1 blocks a second one.
How it works
Trying to enter a value already in the column is rejected. The check column shows what the rule evaluates.
| A | B | |
|---|---|---|
| 1 | Employee ID | COUNTIF |
| 2 | E-100 | 1 → OK |
| 3 | E-101 | 1 → OK |
| 4 | E-100 | 2 → rejected |
The formula
The Data Validation Custom formula (with the top cell of the selection as the reference):
How it works
The rule allows an entry only if it stays unique:
- Select the whole column range first (e.g.
A2:A1000) so the rule covers every entry cell. - Data → Data Validation → Allow: Custom, and enter
=COUNTIF($A$2:$A$1000, A2) <= 1— the list range is locked, the test cellA2is relative. - When you type a value, COUNTIF counts how many times it now appears. A unique value counts 1 (allowed); a duplicate counts 2 (rejected).
- Excel blocks the duplicate and shows an error — add your own message on the dialog’s Error Alert tab.
Validation doesn’t catch pasted duplicates. Pasting can bypass the rule. After a paste, run Data → Data Validation → Circle Invalid Data to flag any duplicates that slipped in.
Try it: interactive demo
Existing IDs: E-100, E-101. Type one to see if it’s accepted.
Variations
Case-sensitive uniqueness
COUNTIF ignores case; use SUMPRODUCT/EXACT to enforce it:
Unique combination of two columns
No repeat of the same name+date pair:
Find existing duplicates
Flag dupes already in the data:
Pitfalls & errors
Reference the right top cell. The Custom formula must use the active cell of the selection (e.g. A2 if the selection starts at A2). Get this wrong and the rule checks the wrong cell.
Paste bypasses validation. Data Validation only fires on typed entries. Use Circle Invalid Data after bulk pastes.
COUNTIF is case-insensitive. “abc” and “ABC” count as the same dupe. Use the EXACT version for case-sensitive IDs.
Practice workbook
Frequently asked questions
How do I prevent duplicate entries in Excel?
How do I prevent duplicates across two columns?
Does data validation stop pasted duplicates?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class