Last updated on November 9th, 2026 at 01:46 pm
To clean data in Excel, work on a copy, then fix problems in this order: remove blank rows and stray totals, strip extra spaces and hidden characters with =TRIM(CLEAN(A2)), make capitalization and spellings consistent, convert numbers and dates stored as text, split or combine columns, remove duplicates with Data > Remove Duplicates, and deal with blanks and errors. Paste your cleaned helper columns back as values, check the totals, and add Data Validation so the same mess doesn’t come back. If you clean the same kind of file every week, record the steps once in Power Query and refresh. If the data arrives with rows and columns the wrong way round, transpose it in Excel before you start. The spaces step is covered in detail in removing extra spaces in Excel.
Applies to: Excel for Microsoft 365 (Windows and Mac), Excel 2024, Excel 2021, Excel 2019 and Excel 2016. Most tools also exist in Excel for the web. Functions marked “Microsoft 365” (such as UNIQUE, TEXTSPLIT and XLOOKUP) need a newer version. The overall approach follows Microsoft’s top ten ways to clean your data, with the formulas and menu paths for each step spelled out here.
What messy data looks like
Data you import from another system, paste from a web page or collect through a form rarely arrives ready to use. Here is a small example of an order list with the usual problems, which the rest of this guide fixes:
| Customer | State | Order ID | Amount | Order date |
|---|---|---|---|---|
| ” alex rivera “ | California | C-1001 | 120 | 3/14/2026 |
| “JORDAN LEE” | Calif. | C-1002 | ’85 (text) | 14/03/2026 (text) |
| ” alex rivera “ | California | C-1001 | 120 | 3/14/2026 |
| (blank row) | ||||
| “Priya Shah” plus a hidden line break | CA | C-1003 | 40 | (blank) |
Those problems look small, but they break things. SUM skips the “85” stored as text and counts Alex’s repeated order twice, so a column that should total 245 shows 280. A lookup for “Alex Rivera” fails because of the extra spaces. A PivotTable lists California, Calif. and CA as three different states. Cleaning first means your formulas, charts and PivotTables reflect what’s really in the data.
Keep the original and use helper columns
- Keep the original. Save a copy of the workbook, or right-click the sheet tab, choose Move or Copy, check Create a copy and select OK. Remove Duplicates, Find and Replace and deleting rows all change data permanently once you save.
- Know what one row means. Decide whether each row is one order, one customer or one transaction. That decides what counts as a duplicate later: two rows with the same customer can be two genuine orders.
- Use helper columns. Most fixes in this guide are formulas. Insert an empty column next to the messy one, put the formula there, check it, then paste the results back as values (covered in Replace the original with clean values).
- Turn the range into a table. Click inside the data and press Ctrl + T (or select Home > Format as Table). A formula typed in one row of a table column fills the whole column automatically, and filter arrows appear on every header.
Spot the problems first
A few minutes of looking saves guesswork later:
- Open the filter arrow on each column. The list of values shows misspellings, odd capitalization and blanks at a glance, because variations such as “Calif.” and “California” sit near each other.
- Look at alignment. In a column formatted as General, real numbers line up on the right, while numbers stored as text line up on the left and often show a small green triangle in the cell’s corner.
- Use =LEN(A2) to find invisible characters. “Jordan Lee” is 10 characters; if LEN returns 11, something hidden is there. =CODE(RIGHT(A2,1)) tells you what the last character is: 32 is a normal space, 160 is a non-breaking space from a web page, and 10 is a line break.
- Use =ISNUMBER(D2) on a column that should hold numbers. Any FALSE is a value Excel will skip in calculations.
What order should I clean data in?
Fix the layout first (headers, blank rows, totals), then the contents of cells (spaces, hidden characters, case, spellings, numbers and dates), and remove duplicates last. Duplicates can only be detected reliably once the values are consistent, and removing them early can leave near-duplicates behind.
Does cleaning data with formulas change the original cells?
No. A formula like =TRIM(A2) shows a cleaned version in another cell and leaves A2 as it was. The original only changes when you paste the results back as values, which is why that step comes after you’ve checked them.
Step 1: Fix the structure
Cell-level cleaning goes faster once the layout is right. Your data should be one header row, then one record per row, with no gaps.
- Delete title rows, notes and merged cells above the header row so the first row of the data is the column names.
- Press Ctrl + End to jump to the last used cell. Delete any total or subtotal rows at the bottom; you can recalculate totals later, and leaving them in doubles your sums.
- Remove completely blank rows. Click any cell in a column that is always filled in a real record (such as Order ID), select Home > Sort & Filter > Filter, open that column’s filter arrow and select only (Blanks). Select the visible rows by their row numbers, right-click and choose Delete Row, then clear the filter.
Blank rows matter because Excel treats a blank row as the end of a list. Sorting, filtering and Ctrl + T stop at the gap and leave the rows below it out.
Warning: You may see a shortcut that uses Go To Special > Blanks on the whole range and then deletes the rows. That also deletes any real record with just one empty cell, such as Priya’s row with its missing date. Only use it on a single column where a blank truly means the whole row is empty.
Extra spaces and invisible characters are the most common reason lookups, matches and Remove Duplicates fail on data that looks fine.
- Insert a helper column to the right of the column you want to clean.
- In the first data row of the helper column, type =TRIM(A2) and press Enter. TRIM removes spaces at the start and end and reduces runs of spaces between words to one, so ” alex rivera ” becomes “alex rivera”.
- If the data came from a web page, use =TRIM(SUBSTITUTE(A2,CHAR(160),” “)) instead. Microsoft’s TRIM function page notes that TRIM only removes the normal space (character 32) and leaves the non-breaking space (character 160) behind. SUBSTITUTE swaps those for normal spaces first.
- For data exported from other systems, add CLEAN, which removes non-printing characters such as line breaks and control codes: =TRIM(CLEAN(SUBSTITUTE(A2,CHAR(160),” “))).
- Fill the formula down (in a table it fills automatically), then check that LEN now returns the length you expect.

One catch with CLEAN: it deletes a line break without putting a space in its place, so “Priya” and “Shah” on two lines inside one cell become “PriyaShah”. When cells contain line breaks between words, swap them for spaces instead: =TRIM(SUBSTITUTE(A2,CHAR(10),” “)) returns “Priya Shah”. For a closer look at stray leading spaces, see how to remove a space before text in Excel.
Step 3: Make capitalization consistent
Excel’s three case functions each take one cell:
- =PROPER(B2) capitalizes the first letter of each word: “JORDAN LEE” becomes “Jordan Lee”. Good for names and cities.
- =UPPER(B2) makes everything capitals: useful for state codes, product codes and IDs.
- =LOWER(B2) makes everything lowercase: useful for email addresses and usernames.
You can nest them with the cleanup from Step 2, for example =PROPER(TRIM(A2)), which turns ” alex rivera ” into “Alex Rivera” in one go.
PROPER capitalizes any letter that follows a non-letter, so check its results on names and business names. “o’neil” correctly becomes “O’Neil”, but “priya’s cafe” becomes “Priya’S Cafe”, “3rd street” becomes “3Rd Street”, and “mcdonald” becomes “Mcdonald”. Fix those few cells by hand or with Find and Replace afterward. There is more on case changes in the guide to capitalizing each word in Excel.
Step 4: Standardize spellings and labels
When one thing is entered several ways (California, Calif., CA), Excel counts each version separately. Pick one standard value per item and replace the rest.
Use Find and Replace for a handful of variations
- Select only the column you want to change, so other columns aren’t touched.
- Press Ctrl + H (or select Home > Find & Select > Replace).
- Type the variation in Find what (for example, Calif.) and the standard value in Replace with (CA).
- Select Options and check Match entire cell contents. Without it, replacing “CA” inside other text could change words such as “CAMDEN”.
- Select Replace All. Excel reports how many replacements it made. Repeat for each variation.
Find and Replace is also the quickest way to strip unwanted characters such as currency symbols, units (“kg”, “pcs”) or asterisks: put the character in Find what, leave Replace with empty and select Replace All. A tilde is needed before a literal asterisk or question mark (~* or ~?), because those are wildcards. The full set of options is covered in Find and Replace in Excel.
Use a lookup table for many variations
If there are dozens of variations, build a two-column mapping list: the messy value in one column and the standard value next to it. In Excel for Microsoft 365 or Excel 2021 and later, =XLOOKUP(B2,$F$2:$F$6,$G$2:$G$6,B2) returns the standard value when it finds a match and keeps the original value when it doesn’t. With “California” and “Calif.” mapped to “CA”, a “TX” that isn’t in the list stays “TX”. The lookup ignores capitalization, so “calif.” matches “Calif.”. You can reuse the list every time you get a new file.
How do I check spelling in a column of data?
Select the column and press F7 (or select Review > Spelling). Add product names and company names to the dictionary with Add to Dictionary so they aren’t flagged every time.
Step 5: Convert numbers stored as text
Numbers stored as text look right but are skipped by SUM, AVERAGE and PivotTable totals. Clean any spaces first (Step 2), then use one of these methods, documented in Microsoft’s guide to converting numbers stored as text:
- Error button (quickest). Select the cells with the green triangle, select the warning button that appears next to them and choose Convert to Number. The values move to the right side of the cell. If no triangle appears, go to File > Options > Formulas and check Enable background error checking.

- VALUE formula. In a helper column, enter =VALUE(D2). “1,250” becomes the number 1250. Combine it with cleanup when needed: =VALUE(TRIM(D2)).
- Paste Special multiply (whole range at once). Type 1 in an empty cell formatted as General and copy it. Select the text numbers, choose Home > Paste > Paste Special, select Multiply under Operation and select OK. Delete the 1 afterward.
- Text to Columns. Select a single column, choose Data > Text to Columns and select Finish straight away. Excel re-enters every value, converting text numbers as it goes.
Some systems export negative amounts with the minus sign at the end, such as “156-“. Microsoft’s suggested fix is =LEFT(D2,LEN(D2)-1)*-1, which returns -156. Text to Columns can also convert trailing minus signs: its Advanced settings on the last screen include a Trailing minus for negative numbers option.
If the cells are formatted as Text, newly converted values can turn back into text when you edit them. Change the format to General or Number under Home > Number Format first. And leave codes that need leading zeros, such as ZIP codes and some account numbers, as text on purpose.
Step 6: Fix dates stored as text
A real Excel date is a number underneath (March 14, 2026 is 46095), which is why it can be sorted, filtered by month and used in calculations. Dates imported as text can’t, and they usually sit on the left side of the cell.
Convert a whole column with Text to Columns
- Select the date column.
- Select Data > Text to Columns, choose Delimited and select Next twice.
- On the third screen, under Column data format, choose Date and pick the order the text is written in: MDY for 3/14/2026 or DMY for 14/03/2026.
- Select Finish, then apply a date format from Home > Number Format (Short Date or Long Date).
The order you choose matters most for dates like 01/05/2026, which is January 5 in MDY and May 1 in DMY. Excel can’t tell from the text alone, so check where the file came from before converting.
Convert individual dates with DATEVALUE
In a helper column formatted as General, =DATEVALUE(E2) turns a text date into its serial number (46095 for “3/14/2026” on a computer set to US date order). Apply a date format to show it as a date. Microsoft’s page on converting dates stored as text also covers text dates with two-digit years, which the error button can convert to 19XX or 20XX.
If the dates are real dates but simply look inconsistent, you only need a new display format; see how to convert the date format in Excel.
Step 7: Split or combine columns
Cleaning often means pulling apart a column that holds two things, such as “Rivera, Alex”, or joining columns that belong together.
- Text to Columns (Data > Text to Columns) splits on a delimiter such as a comma or space. It writes into the columns to the right, so insert empty columns first or set a different Destination on the last screen.
- Flash Fill follows an example. Type the result you want for the first row, such as “Alex” next to “Rivera, Alex”, then press Ctrl + E or select Data > Flash Fill, as described on Microsoft’s Flash Fill page. The results are typed values, not formulas, so they don’t update if the source changes. Scan the column for rows it guessed wrong.
- TEXTSPLIT (Microsoft 365 and Excel 2024): =TEXTSPLIT(A2,”, “) spills “Rivera” and “Alex” into two cells.
- To combine, use =A2&” “&B2 or =TEXTJOIN(” “,TRUE,A2:C2), which skips empty cells.
Each of these is shown step by step in the guide to splitting columns in Excel. For a worked example with multi-word cities and ZIP+4 codes, see how to separate city, state, and ZIP in Excel.
Step 8: Remove duplicates
Remove duplicates after you have cleaned spaces, capitalization and spellings. Before cleaning, “C-1002” and “C-1002 ” (with a trailing space) are different values, so Excel won’t treat those rows as duplicates.
- Click any cell in the data. For a first look, select the column and choose Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values to see which entries repeat.
- Select Data > Remove Duplicates.
- Under Columns, check only the columns that together identify a duplicate record. For the order list, Order ID alone is enough. Checking only Customer would delete every repeat order from the same person.

- Select OK. Excel reports how many duplicate values were removed and how many unique values remain.
Excel keeps the first occurrence and deletes the rest of each matching row. Per Microsoft’s guide to filtering for unique values or removing duplicates, it compares what is displayed in the cell, so the same date shown as “3/8/2026” and “Mar 8, 2026” counts as two different values, and it doesn’t work on data that has an outline or subtotals. To flag duplicates without deleting anything, use =COUNTIF($C$2:$C$100,C2)>1, which returns TRUE for every repeated Order ID. In Microsoft 365, =UNIQUE(A2:E100) creates a de-duplicated copy elsewhere and leaves the original untouched. Advanced Filter, Power Query and other approaches are compared in How to Remove Duplicates in Excel.
Step 9: Handle blank cells and errors
Not every blank needs filling. A missing order date should usually stay blank or get a clear placeholder, not a made-up value, and putting 0 in a missing amount drags averages down.
To select every blank cell in a column so you can fill or review them:
- Select the column or range.
- Press Ctrl + G (or F5), select Special, choose Blanks and select OK. Only the empty cells stay selected.
- Type a placeholder such as Unknown and press Ctrl + Enter to put it in every selected cell at once.
A handy variation for reports where a category is only written once at the top of each group: after selecting the blanks, type =, press the Up Arrow key, then press Ctrl + Enter. Each blank copies the value above it. Paste the column as values afterward. More ways to find empty cells are in the guide to selecting all blank cells in Excel.
The same Go To Special dialog finds formula errors: choose Formulas, leave only Errors checked and select OK. Fix the cause where you can (usually text where a number should be). Where an error is expected, such as a lookup for a new customer that isn’t in the list yet, wrap the formula in IFERROR: =IFERROR(D2/E2,””) shows a blank instead of #DIV/0!.
Step 10: Replace the original with clean values
Once a helper column shows the right results, swap it in for the original:
- Select the helper column’s cells and press Ctrl + C.
- Click the first cell of the original column, select the arrow under Home > Paste and choose Paste Values (the clipboard icon with 123). In Excel for Microsoft 365 on Windows, Ctrl + Shift + V also pastes values.
- Check a few cells: the formula bar should show plain text or numbers, not a formula.
- Delete the helper column.
Pasting values matters. If you delete the original column while the helper still holds formulas, the formulas lose their source and show #REF! errors.
Step 11: Check that the data is clean
- Open each column’s filter arrow again. You should see one spelling per item and no unexpected (Blanks).
- Compare =COUNT(D2:D100) with =COUNTA(D2:D100) on a number column. COUNT counts numbers only and COUNTA counts every non-empty cell, so matching results mean no text is hiding among the numbers.
- Check that totals make sense. In the example, the Amount column now adds up to 245 instead of 280 once “85” is a number and the duplicate row is gone.
- Run descriptive statistics in Excel on numeric columns. A strange minimum, maximum or count points straight at rows that still need attention.
Step 12: Stop bad data coming back with Data Validation
If people will keep typing into the sheet, restrict what they can enter so the same problems don’t reappear.
- Select the cells to protect, such as the State column.
- Select Data > Data Validation.
- On the Settings tab, under Allow, choose List and type the allowed values separated by commas (CA,NY,TX), or choose Whole number, Decimal, Date or Text length with limits.
- On the Error Alert tab, keep the Stop style to block invalid entries, and write a short message explaining what’s allowed.
- Select OK. A List rule adds a drop-down arrow to each cell.
Microsoft’s page on applying data validation to cells lists every option. Validation checks what people type; values pasted over a validated cell may get through without a warning, so a quick filter check now and then is still worth doing. For a fuller walkthrough, see how to use data validation in Excel.
Option: let Clean Data suggest fixes (Microsoft 365)
Some Microsoft 365 subscribers with Copilot have a Clean Data button on the Data tab in Excel for Windows and Excel for the web. According to Microsoft’s Clean Data in Excel page, it scans the data and suggests fixes for three problems: the same text written with different capitalization, punctuation or accents; columns that mix numbers and numbers stored as text; and extra leading, trailing or repeated spaces. You review and apply each suggestion in a side pane. Microsoft says it works best on tables of up to 100 columns and 50,000 rows, is still rolling out, and may give no suggestions or inaccurate ones, so treat it as a helper alongside the steps above, not a replacement. If you don’t see the button, your version or region doesn’t have it yet.
Use Power Query for cleaning you repeat
If a new export with the same problems arrives every week, Power Query lets you record the cleaning once and replay it. Each change you make is saved as a step in the Applied Steps list, and when you refresh, every step runs again on the new data.
- Click inside your data and select Data > From Table/Range. Excel asks to make it a table if it isn’t one, then opens the Power Query Editor.
- Select a column, then use Transform > Format > Trim, Clean or Capitalize Each Word.
- Use Home > Remove Rows > Remove Blank Rows or Remove Duplicates, and Home > Replace Values to standardize labels.

- Set each column’s type (Whole Number, Date, Text) with the icon at the left of the column header.
- Select Home > Close & Load. The cleaned data lands on a new sheet.
- Next time, replace the source data and select Data > Refresh All.
Power Query’s Trim removes spaces only from the start and end of each value, not repeated spaces between words, so check names with double spaces. Microsoft’s overview, About Power Query in Excel, notes that Power Query isn’t available in Excel 2016 or 2019 for Mac. If you can’t find the commands, see how to find and enable Power Query in Excel.
Can I clean data in Excel for the web or on a Mac?
Yes. TRIM, CLEAN, PROPER, Find and Replace, Remove Duplicates, Text to Columns and Data Validation work in Excel for the web and Excel for Mac. Power Query editing is available in Microsoft 365 on Mac and in Excel for the web, but not in Excel 2016 or 2019 for Mac.
How can I automate data cleaning in Excel?
Power Query is the most practical route: it saves each step and reruns them all when you refresh. Macros (VBA) and Office Scripts can also repeat a fixed sequence of actions, but they take more setup and, for macros, a macro-enabled workbook.
With the data clean, you can categorize data in Excel so it’s ready to summarize in a PivotTable or chart.
Which tool to use
| Situation | Best fit |
|---|---|
| One-off file, a few problems | Formulas in helper columns, Find and Replace, Remove Duplicates |
| A pattern that’s easy to show but hard to write as a formula | Flash Fill (check the results) |
| Same messy export every week or month | Power Query, then Refresh All |
| Microsoft 365 with Copilot and inconsistent text or spacing | Clean Data suggestions, then the manual steps for anything left |
| Other people keep typing into the sheet | Data Validation after cleaning |
Spaces and duplicates that survive cleanup
TRIM didn’t remove the space
It’s almost certainly a non-breaking space (character 160) from a web page or PDF. Confirm with =CODE(RIGHT(A2,1)), then use =TRIM(SUBSTITUTE(A2,CHAR(160),” “)).
Remove Duplicates missed rows that look identical
The rows differ by a space, a hidden character or capitalization you can’t see. Run Steps 2 to 4 on the key columns, paste the results as values, and run Remove Duplicates again.
Numbers still won’t add up
They may contain a currency symbol, unit or non-breaking space, or the column may be formatted as Text. Strip the characters with Find and Replace, set the format to General, then convert with VALUE or Text to Columns. =ISNUMBER(D2) should return TRUE afterward.
Excel changed my codes into dates or dropped leading zeros
Excel converts entries such as 3-14 or 00123 when they’re typed or imported into General cells. Format the column as Text before entering or importing, and see how to stop Excel from changing numbers to dates.
Text to Columns overwrote my data
It writes into the columns to the right of the selection. Press Ctrl + Z right away, insert enough empty columns, and run it again, or set a Destination on the final screen.
Flash Fill gave odd results
Give it more examples. Type the correct result in two or three rows, including an unusual one, then press Ctrl + E again.
Undo a cleaning step
Press Ctrl + Z immediately after a mistake; Excel can undo Remove Duplicates, Replace All and Text to Columns while the file is still open. If you have already saved and closed it, open your untouched copy. For files stored in OneDrive or SharePoint, File > Info > Version History lets you open an earlier version.

Matt Jacobs writes and maintains the guides on Support Your Tech, which he started in 2017. He spent most of his career keeping small-business PCs running and still takes the occasional consulting job, so the steps here come from fixing the same problems on other people’s computers. Every guide is checked on his own Windows 11, Windows 10, Mac, iPhone and iPad before it goes up.