Cleaning Messy Data in Excel: Duplicates, TRIM, Text-to-Columns, Power Query
Working through a deliberately filthy customer export, in the order that actually gets it clean

Working through a deliberately filthy customer export, in the order that actually gets it clean

Most Excel cleaning tutorials use a tidy practice sheet with one deliberate flaw, a single duplicate row, a single stray space, easy to spot and easy to fix in isolation. Real exports don't arrive that way. They arrive with all of it at once, trailing spaces, duplicate rows that don't look like duplicates because of those spaces, dates in two different formats, and a combined field that should really be two columns. This guide works through one genuinely messy sheet using all four techniques, in the order that actually gets it clean rather than the order that looks cleanest in a tutorial.
# | Technique | What it helps you do |
|---|---|---|
1 |
| Standardise messy text and remove unwanted characters |
2 | Remove Duplicates | Eliminate repeated records after cleaning |
3 | Text to Columns | Split combined fields into separate columns |
4 | Date cleaning | Handle inconsistent date formats safely |
5 | Power Query | Turn one-time cleaning into a repeatable workflow |
The data, a customer export:
Customer Name | Full Address | Signup Date | Status |
|---|---|---|---|
Rahul Sharma | 12 MG Road, Bangalore | 03/12/2026 | active |
rahul sharma | 12 MG Road, Bangalore | 2026-03-12 | Active |
Priya Iyer | 45 Anna Salai, Chennai | 15/03/2026 | ACTIVE |
Vikram Nair | 8 Park Street, Kolkata | 03/18/2026 | inactive |
Priya Iyer | 45 Anna Salai, Chennai | 15/03/2026 | active |
Look closely and this table already has three of the four problems this guide covers: in the raw export, Rahul Sharma has a trailing space after the name, while the status values use inconsistent capitalisation. Rows 1 and 2 represent the same customer, but the whitespace difference needs to be cleaned before the records are compared. The trailing space after Rahul Sharma is not visually obvious in the table, which is exactly why this kind of issue is easy to miss in a real export. Priya Iyer also appears twice with inconsistent status capitalisation. And "Full Address" is really two pieces of information, street address and city, stuck together.
It's tempting to jump straight to Data → Remove Duplicates, since duplicates feel like the obvious first problem. Don't. Clean the text first so that accidental whitespace and other formatting inconsistencies are removed before you compare records. For example, a value such as Rahul Sharma with a trailing space is different from Rahul Sharma when the underlying text values are compared. Standardising the text first makes the duplicate check more reliable and gives you a cleaner dataset to work with.
Show Image
The fix is sequencing, not a better tool. Clean the text first, then deduplicate. That single ordering decision is the difference between this workflow actually working and silently leaving duplicates behind.
=TRIM(A2)TRIM removes leading and trailing spaces and collapses multiple internal spaces down to one. Apply it to every text column that might have inconsistent spacing, in this case Customer Name and Status, in a helper column, then paste the results back as values before moving on.
For capitalisation inconsistency, "active" vs "ACTIVE" vs "Active", PROPER or UPPER applied consistently across the column normalises it the same way TRIM normalises whitespace:
=PROPER(TRIM(A2))Nesting TRIM inside PROPER handles both problems in one formula: strip the stray whitespace, then standardise the capitalisation. Run this on Customer Name and Status before doing anything else.
Where this bites people: leaving the cleaned results in helper columns and then removing or changing the formulas later can make the workflow harder to audit or reproduce. Once you've verified the cleaned values, copy the results and use Paste Special → Values to replace the helper formulas with fixed values before deduplicating.
With the Customer Name and Status cleaned and pasted as values, Data → Remove Duplicates can now correctly identify rows 1 and 2 as the same customer because the trailing whitespace that made the underlying values different has been removed. Select all the columns that should match for a row to count as a true duplicate, not just Customer Name alone, since two different customers could coincidentally share a name.
Where this bites people: selecting every column including a column that's expected to vary, like a row ID or timestamp added during export. If that column is included in the duplicate check, genuinely duplicate customer records won't be caught, because that one column makes every row technically unique. Uncheck columns that aren't part of what actually defines a duplicate here.
"Full Address" mixes two pieces of information, street address and city, separated by a comma. Select the column, then Data → Text to Columns → Delimited → Comma, and Excel splits it into two columns at each comma.
Where this bites people: running Text to Columns without enough empty space immediately to the right. Excel can overwrite data in the columns immediately to the right of the original column, so make sure there is enough empty space before running it. Insert blank columns before splitting if necessary.
The mixed date formats in the original table, 03/12/2026 next to 2026-03-12, are a related but separate problem: Text to Columns can help isolate a date string, but fixing an actual mixed-format date column usually needs a combination of DATEVALUE and manual inspection, since Excel can silently misinterpret an ambiguous date like 03/12/2026 as either the 3rd of December or the 12th of March depending on regional settings. When a date column looks inconsistent, check the format explicitly rather than trusting AutoFit to catch it.
Everything above works well for a single cleanup. The real limitation shows up the next time this same export lands in your inbox next week, since none of the steps above are remembered; you'd redo every one of them by hand.
This is exactly the problem Power Query solves. The same TRIM, capitalisation, deduplication, and column-splitting logic can be built once inside Power Query's Transform Data editor, and it reapplies automatically every time the underlying file refreshes. For a cleanup you'll only ever do once, the manual steps above are the faster path. For anything recurring, monthly exports, a live data source, weekly reports, building the same logic in Power Query once is the better long-term investment, and it's the same underlying tool that sits inside Power BI too, so the skill transfers directly.
Deduplicating before cleaning text. Trailing spaces and other text inconsistencies can hide real duplicates from a value-based comparison. Clean the text before running Remove Duplicates.
Leaving cleaning formulas in place when you no longer need them. Once you've verified the results, use Paste Special → Values to freeze the cleaned data and make the final dataset easier to audit and work with.
Including a column that's expected to vary in the duplicate check. A row ID or export timestamp included in the comparison makes every row look unique, defeating the point of deduplicating at all.
Running Text to Columns without enough empty space for the split data. Excel can overwrite data in the columns immediately to the right of the original column, so make sure there is enough empty space before splitting.
Not keeping a copy of the original messy data. Cleaning steps are hard to undo once several are stacked on top of each other; keep the raw export on a separate tab before you start.
Trusting a date column's display format without checking it. A date that displays consistently can still be stored inconsistently underneath, especially after combining two exports from different regional settings.
This guide covers the manual cleaning toolkit; for the fuller working set of Excel skills these fit into, cleaning, lookups, Pivot Tables, and Power Query together, the Excel for Data Analysis guide is the place to go next. If TRIM, PROPER, and the other formulas used here felt unfamiliar, the Excel formulas guide covers them alongside the rest of the working set analysts use weekly.
Power Query is genuinely the same tool inside Power BI, so if you're heading that direction next, the Power BI for Beginners tutorial picks up cleaning exactly where this guide leaves off, applied to a multi-table model rather than a single sheet.
Quiz
Question 1 of 15
FAQ