DEV Community

Nguyen Hiep
Nguyen Hiep

Posted on

How to remove duplicate customers in Excel when the duplicates don't match exactly

Excel's Remove Duplicates button works well when two rows are identical. Customer lists rarely are. The same person shows up as:

Name Email Phone
OLIVIA BROWN olivia.brown@example.com 07700 900101
Olivia Brown OLIVIA.BROWN@EXAMPLE.COM␠
james wilson james.w@example.org 07700 900102
James Wilson james.w@example.org. +44 7700 900102

To Excel these are four different rows. To you they're two customers. Here's how to fix that, from the quickest manual method to a repeatable one.

1. Normalise first, then remove duplicates (pure Excel)

Duplicates hide behind capital letters, stray spaces and trailing punctuation. Add helper columns:

  • Clean email: =LOWER(TRIM(SUBSTITUTE(B2,CHAR(160)," ")))
  • Clean name: =PROPER(TRIM(A2))
  • Phone digits only (Excel 365): =TEXTJOIN("",TRUE,IFERROR(MID(C2,SEQUENCE(LEN(C2)),1)*1,""))

Then run Data › Remove Duplicates on the clean email column only.

Watch out:

  • PROPER turns "McDonald" into "Mcdonald". Only apply it to names that are ALL CAPS or all lowercase.
  • Remove Duplicates keeps the first row and silently drops the others. If the second row had the phone number and the first didn't, you lose it. Fill the blanks before removing (sort so the most complete row comes first).
  • Never merge on name alone. Two "Amelia Clarke"s with different emails are usually two different people.

2. Phone numbers in five formats

07700 900102, +44 7700 900102 and 0044 7700900102 are the same number. Compare the last 9 digits of the digits-only column. That ignores country prefixes and leading zeros, and works for most countries.

3. Dates: 03/04/2025 — March or April?

If your list came from UK and US sources, 03/04/2025 is ambiguous. Excel guesses based on your system locale, often wrong for half the rows. Decide which order the source used, and flag any date where both parts are ≤ 12 for a human to check instead of guessing.

4. A repeatable way: a short Python script

If you do this every month, script it. CleanList Lite (free, MIT) does steps 1–2 in one command and writes a change log so you can see every edit:

pip install pandas openpyxl
python cleanlist_lite.py customers.csv -o cleaned.xlsx --country-code 44
Enter fullscreen mode Exit fullscreen mode
Rows read: 10 -> unique customers: 8 (2 duplicates merged, 15 values tidied)
Enter fullscreen mode Exit fullscreen mode

It only merges rows with the same valid email, which is the safest rule. Your original file is never modified.

5. When the list is really messy

Several exports, merged cells, mixed date formats, customers who changed email but kept their phone? That's where simple rules break. I built CleanList for that: a Windows app (no Python needed) that merges several files at once, matches by phone + similar name (accent-insensitive), keeps same-name-different-person apart and lists every uncertain case in a "Needs review" sheet. It runs offline, and there is a free version for up to 300 rows per run.

Checklist

  1. Work on a copy. Never on the original.
  2. Normalise case, spaces and punctuation before comparing.
  3. Merge only on hard evidence (same email, or same phone + similar name).
  4. Fill blanks from the duplicate before deleting it.
  5. Keep a log of what changed, so you can undo or explain it.

Disclosure: I'm the author of CleanList and CleanList Lite.

This article was written with AI assistance (Claude).

Top comments (0)