A duplicate invoice number usually means the same invoice was entered twice, and it will double-count in every total. A custom validation rule using COUNTIF checks each new entry against the whole column and rejects it the moment it appears a second time.
What you need
- Excel with the identifier column ready, such as invoice numbers
- The existing identifiers, already checked for duplicates
- A note of the exact range the rule covers
Step 1: Write the COUNTIF rule for the first cell
Select the identifier column, open Data, Data Tools, Data Validation, choose Allow: Custom, and enter the formula =COUNTIF($A$2:$A$100,A2)=1, adjusted to your column and first cell. The absolute range stays fixed while the single-cell reference moves row by row.
Step 2: Test the formula on the sheet first
Before relying on the dialog, type the same formula in a helper cell and confirm it returns TRUE for a new value and FALSE for a value already in the column. Debugging inside the dialog is difficult; the sheet shows the answer.
Step 3: Try entering a duplicate
Type an identifier that is already in the column and confirm Excel blocks it with the error alert. Then type a new identifier and confirm it is accepted.
Worked example: synthetic invoice numbers INV-101 to INV-110
The table below is a synthetic example. It shows the expected result of testing a no-duplicates rule; no workbook was opened.
| Entry tested | Already listed? | Result |
|---|---|---|
| INV-111 | No | Accepted |
| INV-104 | Yes | Blocked |
| INV-112 | No | Accepted |
| INV-101 | Yes | Blocked |
Expected result (UNTESTED). the two new invoice numbers are accepted and the two already-listed numbers are blocked. The COUNTIF rule stops duplicates at entry. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- The rule only checks values typed in; pasting a duplicate over a cell can bypass it.
- Trailing spaces make two values look the same but count as different; trim the column first.
- The range in the formula must cover the whole column, or entries below it are unchecked.
