Cleaning text in Excel means removing the invisible problems that make data hard to sort, match, or summarize: extra spaces, non-printing characters, inconsistent capitalization, line breaks, and text that looks like a number but is stored as text. The fastest fix is usually a combination of TRIM and CLEAN, followed by Paste Special or Text to Columns for numbers. No add-ins are required — everything below uses built-in Excel functions and tools available in Excel for Microsoft 365, Excel 2021, Excel 2019, and Excel for the web. Menu labels can differ slightly by version, platform, and region, so if a button name looks different, look for the closest match.
What You'll Need
- Excel for Microsoft 365, Excel 2021, Excel 2019, or Excel for the web (the functions used here — TRIM, CLEAN, SUBSTITUTE, VALUE, TEXTJOIN — are all standard).
- A backup copy of your workbook, or work on a duplicate sheet, because cleaning overwrites original values.
- At least one spare column to hold the cleaned results before you replace the originals.
Step-by-Step
- Make a copy of the sheet. Right-click the sheet tab and choose Move or Copy, tick Create a copy, and click OK. Work on the copy so the original data stays intact if something goes wrong.
- Identify the problems. Select the column you want to clean and look at the status bar at the bottom of the window. If it shows Count but not Sum for a column of numbers, those values are stored as text. Extra spaces are harder to see — a quick check is to compare two cells that look identical with
=A2=B2; FALSE usually means hidden spaces or characters. - Add a helper column. In the first empty column to the right of your data, put a header such as Cleaned. In the first row of data (say row 2), enter
=TRIM(A2). TRIM removes leading and trailing spaces and collapses multiple spaces between words into a single space. - Wrap in CLEAN for non-printing characters. Change the formula to
=TRIM(CLEAN(A2)). CLEAN strips the first 32 non-printing ASCII characters, which often arrive when data is copied from websites or PDFs. - Fix non-breaking spaces. CLEAN does not remove the non-breaking space (character 160) that web pages often insert. If TRIM(CLEAN(...)) still leaves a gap, use
=TRIM(CLEAN(SUBSTITUTE(A2,CHAR(160)," "))). This replaces each non-breaking space with a normal space, which TRIM can then collapse. - Fill the formula down. Double-click the fill handle (the small square at the bottom-right of the selected cell) to copy the formula to the last row of data. Check a few results against the originals.
- Convert the formulas to values. Select the helper column, press Ctrl+C (Cmd+C on Mac), then right-click and choose Paste Special > Values. This replaces the formulas with plain text so you can delete the original column without breaking references.
- Replace the original data. Copy the cleaned values, select the first cell of the original column, and use Paste Special > Values again. Delete the helper column.
- Convert text-numbers to real numbers. Select the column, then use Data > Text to Columns, click Finish without changing any settings. Excel re-evaluates each cell and converts numeric-looking text to numbers. Alternatively, multiply the range by 1 using Paste Special > Multiply. The status bar should now show Sum.
- Standardize capitalization. Use
=UPPER(A2),=LOWER(A2), or=PROPER(A2)in a helper column. PROPER capitalizes the first letter of each word, which is useful for names but will also capitalize small words like "of" — review before replacing. - Remove line breaks inside cells. If a cell contains Alt+Enter line breaks, use Find and Replace (Ctrl+H). In Find what, type Ctrl+J (a small blinking dot appears). Leave Replace with blank and click Replace All. This removes the line breaks without touching the text.
- Split combined text if needed. If a column holds "Last, First" or "City, State", use Data > Text to Columns > Delimited and choose the separator (comma, space, semicolon). Preview the result before clicking Finish.
Common Mistakes
- Cleaning the original column first. Always work on a copy or a helper column. Once you overwrite values, the original formatting and any hidden characters are gone.
- Forgetting non-breaking spaces. TRIM alone will not remove them, and the cell will still fail lookups. Use the SUBSTITUTE + CHAR(160) formula when data comes from the web.
- Pasting formulas instead of values. If you copy a TRIM formula into the original column, the formula references shift and return wrong results. Always use Paste Special > Values.
- Assuming PROPER fixes all names. It capitalizes every word, so "McDonald" becomes "Mcdonald" and "van der Berg" becomes "Van Der Berg". Review manually.
- Using Text to Columns on dates. It can silently change date formats depending on your regional settings. Check a sample before applying to the whole column.
Tips
- Use Flash Fill (Ctrl+E) for one-off pattern cleaning, such as extracting the first name from an email address. It is fast but not dynamic — it does not update when the source changes.
- For a whole range at once, TEXTJOIN with the ignore_empty argument can merge cleaned values without extra delimiters, but for simple trimming, a helper column is easier to audit.
- Conditional formatting with the formula
=LEN(A2)<>LEN(TRIM(A2))highlights cells that contain extra spaces, so you can spot problems before cleaning. - If you clean the same workbook regularly, save the helper formulas in a template sheet so you can paste new data underneath and copy the formulas down.
- Keep a column of original values until you have verified the cleaned data with a VLOOKUP or XLOOKUP match test.
Troubleshooting
- TRIM does not remove the spaces. The characters are probably non-breaking spaces. Use the SUBSTITUTE formula from Step 5.
- Numbers still will not sum after cleaning. Check for a leading apostrophe, which forces text format. Select the column, use Text to Columns > Finish, or Paste Special > Multiply by 1.
- The formula returns #VALUE!. The cell may contain an error value or a character Excel cannot interpret. Wrap the formula in IFERROR to see which rows are affected:
=IFERROR(TRIM(CLEAN(A2)),"check"). - Find and Replace will not find Ctrl+J. Make sure you are in the Find what box when you press Ctrl+J, and that the cursor is not in Replace with. If it still fails, use
=SUBSTITUTE(A2,CHAR(10)," ")in a helper column instead. - Cleaned values look right but lookups fail. One column may still be text and the other numeric. Compare with
=ISTEXT(A2)and=ISNUMBER(B2)to confirm, then convert both to the same type.
Frequently Asked Questions
What is the difference between TRIM and CLEAN?
TRIM removes extra spaces (leading, trailing, and repeated spaces between words). CLEAN removes non-printing characters such as line breaks and tabs. Use them together as TRIM(CLEAN(cell)) for the most thorough clean.
Why does TRIM leave a space that I can see but cannot delete?
That is almost always a non-breaking space (character 160), common in text copied from websites. TRIM does not treat it as a space. Replace it with SUBSTITUTE(cell,CHAR(160)," ") before trimming.
Can I clean an entire column at once without a helper column?
Not safely. Excel formulas need a destination cell. You can paste the TRIM formula into the original column, but it will overwrite your data and the references will shift. A helper column followed by Paste Special > Values is the reliable method.
How do I remove line breaks inside a single cell?
Use Find and Replace (Ctrl+H). Click in Find what, press Ctrl+J, leave Replace with empty, and click Replace All. Alternatively, use SUBSTITUTE(cell,CHAR(10)," ") in a helper column.
Does cleaning text change number formatting?
Yes, potentially. Converting text to numbers with Text to Columns or Paste Special > Multiply can drop leading zeros (for example, ZIP codes) and change date interpretation. Format the column as Text before cleaning if leading zeros matter.
Is there a way to clean text automatically as I type?
No. Excel does not clean text on entry. You can use a formula in a separate column, or a Power Query query that applies TRIM and CLEAN each time you refresh, but the source cells themselves are not altered automatically.