How to Remove Duplicate Rows by Multiple Columns in Excel
Excel's built-in Remove Duplicates checks whole rows. Here's how to dedupe by just the columns that matter (name and email, but not phone) using a free macro.
2026-04-28
The problem with Excel's built-in Remove Duplicates
Excel's Data → Remove Duplicates is great when you want to find rows where every column matches. But that's rarely what you actually want when cleaning real data.
Imagine a customer list:
| Name | Phone | Last Order | |
|---|---|---|---|
| Acme Co | sales@acme.com | 555-0100 | 2026-01-15 |
| Acme Co | sales@acme.com | 555-0101 | 2026-03-22 |
| Beta LLC | hi@beta.com | 555-0200 | 2026-02-10 |
The first two rows are clearly the same customer (same name, same email), just with a different phone number recorded on different orders. You want to dedupe by Name + Email while ignoring Phone and Last Order. Excel's built-in tool can't do that. It treats the rows as different because Phone and Last Order differ.
The workarounds people usually try:
- Add a helper column like
=A2&B2and dedupe by that. Works, but it's clunky and you have to remember to delete the helper afterwards. - Use Power Query. Powerful but heavy. Overkill for a one-time cleanup.
- Sort, then delete duplicates manually. Slow, error-prone, doesn't scale.
There's a better way: a small VBA macro that lets you pick exactly which columns matter.
The free tool
Download Remove Duplicates by Multiple Columns. It's a single .xlsm file with one macro. No install, no signup, works offline on Windows and Mac.
How it works:
- Select your data range, including the header row.
- Run the macro from
Alt + F8. - Type the column numbers you want to dedupe by, separated by commas. For the customer table above, you'd enter
1,2(Name and Email). - The macro deletes any row whose chosen-column values match an earlier row, keeping the first occurrence.
The comparison is case-insensitive, so Acme and ACME are treated as the same value. The macro reports how many duplicates it removed.
Why a macro is the right tool here
- It's a one-shot operation. Click the macro, see the result, undo if needed (
Ctrl/Cmd + Zworks). - The behavior is explicit and visible (you choose the columns), with no buried checkbox in a dialog.
- Output is plain values: no helper columns, no Power Query refresh needed, no formulas to break.
Common pitfalls and how to avoid them
Hidden whitespace. Two cells that look like Acme and Acme (trailing space) won't match. They're different strings. Run our Trim Whitespace tool first to normalize spacing.
Different capitalization. This macro is case-insensitive, so it handles Acme vs ACME correctly. But other tools may not, so be careful when copying this approach to other contexts.
Numbers stored as text. A cell containing 1 (number) and a cell containing "1" (text) are different to Excel. If your "Customer ID" column was imported as text in some rows and number in others, dedupe will miss matches. Use Data → Text to Columns to normalize.
No backups. The macro deletes rows. Always work on a copy of your data, not the original. If you hit Ctrl-Z right after running and the undo works, great. But undo isn't guaranteed across all Excel versions for VBA-driven changes.
Next steps
- If you want to see duplicates before deleting them, use Highlight Duplicate Values. It paints duplicate cells red without changing your data.
- If you want to clean up the data quality issues that cause duplicates in the first place, run Trim Whitespace before dedupe to catch the trailing-space cases.
Both tools are free, offline, and work the same way: download, enable macros, run.
FAQ
Can I run this without VBA enabled? No. The tool is a VBA macro, so macros must be enabled when you open the file. If your IT department blocks macros entirely, you'll need to use the helper-column workaround.
Does this work on Excel for the web? No. Excel for the web does not run VBA. This is a desktop-only tool (Windows or Mac).
What if my dataset has more than a million rows? Excel's row limit is just over a million. The macro can handle the full sheet but performance degrades with very large datasets. For 10M+ rows, use Power Query or a database.