How to clean messy data in Excel: 9 fixes

The order we use on client spreadsheets, with tested formulas and the checks that prove nothing was lost.

By ScrillaB · Updated · Written with AI assistance and checked before publishing

Exports from CRMs, web forms, accounting tools and PDFs rarely arrive ready to analyze. Names have stray spaces, numbers won't add up, dates won't sort, and "NY", "N.Y." and "New York" all count as different states. Here are nine fixes in the order we apply them on client spreadsheets, plus the checks that prove nothing was lost along the way. All formulas were tested, and they work in Excel 2019, Excel 2021 and Microsoft 365 unless noted otherwise.

1. Work on a copy, as a table

Keep the original export untouched on its own tab, called Raw or similar, and do all your cleaning on a copy. Then click inside the data and press Ctrl+T to make it an Excel table. Tables fill formulas down automatically and keep filters and sorts on the right range. Before you change anything, note the row count shown in the status bar.

2. Remove extra spaces (when TRIM isn't working)

=TRIM(A2) removes leading and trailing spaces and squeezes double spaces down to one. If TRIM seems to do nothing, the culprit is usually a non-breaking space (character 160), which is common in data copied from web pages and PDFs. TRIM doesn't remove it, so swap it for a normal space first:

=TRIM(SUBSTITUTE(A2,UNICHAR(160)," "))

In our test, a cell containing "  Acme<nbsp>Corp  " came out as a clean 9-character "Acme Corp".

3. Strip line breaks and odd characters

=CLEAN(A2) removes non-printing characters, including the line breaks that appear when someone pressed Alt+Enter in a cell. Combine it with the space fix for a general-purpose text cleaner:

=TRIM(CLEAN(SUBSTITUTE(A2,UNICHAR(160)," ")))

4. Convert numbers stored as text, all at once

Numbers stored as text show up as left-aligned values with green triangles, and SUM ignores them. There are three ways to convert a whole column, depending on what's mixed in with the digits:

Watch for ID numbers such as ZIP codes, part numbers and phone numbers. These should stay as text, or you'll lose leading zeros.

5. Fix dates Excel doesn't recognize

If dates won't sort or group in a pivot table, they're text. The most common cause is a day/month/year export opened on a computer set to month/day/year.

Avoid relying on DATEVALUE for ambiguous dates. It reads text according to your computer's regional settings, so 03/04/2026 could become March 4 or April 3. Once converted, check a few dates where the day is greater than 12, because those can only be read one way.

6. Standardize case and spelling

7. Split or combine columns

8. Remove duplicates safely

Deduplicate after the steps above, because trailing spaces and inconsistent case hide duplicates. Excel always keeps the first occurrence, so sort first to control which row survives. Our full guide on removing duplicates but keeping the latest row walks through it.

9. Handle blanks and errors

When you're done, select your helper columns and use Copy > Paste Special > Values so the clean data no longer depends on the raw tab.

Verify before you hand it over

  1. Row count: the same as the raw tab, minus only the duplicates you removed on purpose.
  2. Totals: =SUM() key number columns on both tabs. They should match, adjusted for any removed duplicates.
  3. Type check: =COUNT(C2:C1000) (numbers only) should equal =COUNTA(C2:C1000) for a number column. A gap means some cells are still text.
  4. Dates: sort oldest to newest and confirm the first and last dates make sense.

Keep a short note of what you changed: "Trimmed names, converted 2 date columns from DMY, removed 37 duplicate emails (kept latest)." That note is what makes cleaned data trustworthy to the next person who opens it. We send one with every cleanup job, and our CSV cleanup sample shows one.

FAQ

Why is TRIM not working in Excel?

TRIM only removes normal spaces. Data from web pages and PDFs often contains non-breaking spaces (character 160), so replace them first: =TRIM(SUBSTITUTE(A2,UNICHAR(160)," ")).

How do I convert all numbers stored as text at once?

Select the column and run Data > Text to Columns > Finish, or Paste Special with Multiply by 1. For values with $ signs or commas, use VALUE with SUBSTITUTE in a helper column.

Why won't my dates sort correctly?

They're stored as text, often day-first dates opened on a month-first computer. Convert them with Text to Columns (choose the Date format and the right order) or with a DATE formula.

What order should I clean data in?

Keep a raw copy, fix spaces and characters, convert numbers and dates, standardize spelling, then remove duplicates last. Finish by checking row counts and totals.