What the video covers
Clean up text in worksheet cells by removing extra spaces (leading, trailing, and repeated spaces between words) using the TRIM function and replace original values if desired.
Watch the video on YouTubeStep-by-step instructions
- Select destination cell
Click the cell where you want the cleaned text to appear (commonly next to the original data). - Enter the TRIM formula
Type =TRIM( and then select the cell that contains the text with extra spaces. Close the parentheses and press Enter. This removes leading, trailing, and extra spaces between words. - Fill down as needed
Copy the formula down the column (drag the fill handle or double-click it) to clean other rows. - Replace originals (optional)
If you want to overwrite the original text, copy the cleaned cells, then Paste Values over the original cells so only the cleaned text remains (not the formula). - Handle non-standard spaces (if needed)
If spaces persist, replace non-breaking spaces by wrapping SUBSTITUTE around the source: use SUBSTITUTE(cell, CHAR(160), " ") inside TRIM, e.g. =TRIM(SUBSTITUTE(A2, CHAR(160), " ")).
Watch the video
Play tutorial
Why it matters
Extra spaces often come from imports or copy-paste and can break formulas, sorting, filtering, and lookups. TRIM standardizes spacing so data behaves as expected.
Check your result
After cleaning, verify by checking formulas, sorting results, or using exact-match functions (e.g., comparing cleaned cells to expected values). You can also visually inspect that leading/trailing spaces are gone and only single spaces remain between words.
Troubleshooting
If TRIM doesn't remove non-breaking spaces (common from web or PDFs), use a SUBSTITUTE step to replace that character (for example: SUBSTITUTE(cell, CHAR(160), " ")) and then apply TRIM. If you need to permanently replace originals, make sure to paste values over the original cells to remove formulas.