Excel data cleaning practice

Clean a messy SKU with TRIM and SUBSTITUTE in the grid below.

In C4, strip the stray "#" and extra spaces from the raw SKU in A4.

Syntax
TRIM(SUBSTITUTE(text, old_text, new_text))
C4
fx
ABC
1Raw SKUItemClean SKU
2 DK-101 Desk
3 CH-204# Chair
4 LM-309# Lamp
5BK-412#Bookcase
6 RG-515 Rug
7ST-620# Stool

Core Excel data cleaning formulas

Real-world CSV exports rarely arrive ready for VLOOKUP or SUMIFS. Keep these six functions on hand to standardize raw columns in seconds:

TRIM(text)=TRIM(" LM-309 ") → "LM-309"

Removes leading, trailing, and repeated internal spaces

SUBSTITUTE(text, old, new)=SUBSTITUTE("LM-309#", "#", "") → "LM-309"

Replaces specific unwanted characters or symbols

CLEAN(text)=TRIM(CLEAN(A4))

Strips non-printing line breaks and control characters from CSV exports

VALUE(text) / --text=VALUE(SUBSTITUTE(A4, "$", ""))

Converts numbers stored as text back into real numeric values

PROPER / UPPER / LOWER=UPPER(TRIM(A4))

Standardizes inconsistent capitalization before grouping or PivotTables

TEXTBEFORE / TEXTAFTER / TEXTSPLIT=TEXTBEFORE(A4, "-") → "LM"

Extracts codes, domains, or fields from delimiter-separated strings

4 mistakes that leave dirty data behind

Running TRIM without SUBSTITUTE

TRIM only removes extra spaces — stray symbols like #, $, or non-breaking spaces (CHAR(160)) stay behind and break exact lookups.

Running SUBSTITUTE without TRIM

Replacing "#" leaves hidden leading or trailing spaces intact. Two cells that look identical on screen still fail VLOOKUP with #N/A.

Stripping all spaces with SUBSTITUTE(A4," ","")

Replacing every space removes spaces between words (turning "New York" into "NewYork"). Use TRIM for spaces and SUBSTITUTE for stray symbols.

Forgetting to paste values before deleting raw data

In desktop Excel, keep your cleaning formula column or use Copy → Paste Values once verified so formulas do not break if raw columns are removed.

FAQ

Does the order of TRIM and SUBSTITUTE matter?

For removing a stray symbol like "#" plus outer spaces, both =TRIM(SUBSTITUTE(A4,"#","")) and =SUBSTITUTE(TRIM(A4),"#","") return the same clean SKU. Wrapping TRIM on the outside is a good default because it also catches any spaces uncovered when a symbol is removed.

Why does VLOOKUP still return #N/A after I use TRIM?

Two common reasons: either the cell contains a web non-breaking space (CHAR(160)) that TRIM does not remove — fix with =TRIM(SUBSTITUTE(A4,CHAR(160)," ")) — or one table stores IDs as text while the other stores them as numbers.

What is the difference between SUBSTITUTE and REPLACE in Excel?

SUBSTITUTE replaces matching text wherever it appears (for example every "#"). REPLACE swaps characters by numeric position (for example 3 characters starting at position 1).

Can I clean messy spreadsheet data without Power Query or VBA?

Yes. Most day-to-day CSV cleanup tasks — stray symbols, trailing spaces, inconsistent case, text-formatted numbers, and split fields — take a single formula combining TRIM, SUBSTITUTE, CLEAN, VALUE, and TEXTSPLIT.