ZonoTools

Excel TRIM Function (Remove Extra Spaces) – Examples & Practice

Practice the Excel TRIM function online with an interactive grid, instant feedback, and clear formula help.

Instruction

Clean text in A2 by removing leading, trailing, and repeated spaces.

Formula Syntax

=TRIM(text)

  • text: The text to remove extra spaces from.

What it does

TRIM removes extra spaces from text so comparisons and lookups behave predictably. It is one of the fastest wins in data cleaning.

Excel TRIM Function Examples

Clean messy text

=TRIM(A2)

Removes leading/trailing spaces and squeezes repeats.

TRIM both sides of a composite key

=TRIM(A2)&"|"&TRIM(B2)

Builds a stable key from two cells after trimming each value (adjust the delimiter to match your data model).

Replace NBSP before TRIM

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

Swaps Excel’s non-breaking space (often pasted from the web) for a normal space, then trims.

text-cleanup.xlsx

AB
1Raw TextHelper
2 ACME Corporation ACME
3Invoice-2026-00012026
4VIP_CLIENTVIP
5John DoeDoe
6 Product Name Product
7Output

Input Formula

Need Help?

Tips

  • TRIM before LOWER when building match keys.
  • Watch for CHAR(160) non-breaking spaces in web data.
  • Document cleaning steps for recurring imports.

TRIM Function Use Cases

  • Normalize names and addresses before dedupe
  • Prepare keys for lookups and merges
  • Reduce false negatives in COUNTIFS
  • Clean CSV imports quickly
  • Preprocess survey responses

Common mistakes - TRIM function not working

  • Assuming TRIM removes every whitespace variant
  • Not keeping a raw column for auditing
  • Applying TRIM too late after failed lookups
  • Expecting TRIM to fix spelling
  • Ignoring NBSP characters from HTML

FAQ

Does TRIM remove all spaces?

TRIM removes leading and trailing spaces and collapses repeated internal spaces to a single space.

TRIM vs CLEAN?

CLEAN removes many non-printable characters; TRIM focuses on spaces.

Will TRIM fix non-breaking spaces?

Not always. SUBSTITUTE may be needed for CHAR(160) style spaces.

Does TRIM change numbers?

If a number is stored as text with spaces, TRIM can help before VALUE conversion.

Can TRIM break formatted text?

It changes the literal string; keep originals if needed.

Comparison

Function Focus
TRIM Spaces
CLEAN Non-printables
SUBSTITUTE Specific replacements

Example

=TRIM(" hi hi ")

Advanced examples

TRIM + CLEAN pipeline

=TRIM(CLEAN(A2)) is a common first pass on pasted web data.

TRIM before LOWER for match keys

=LOWER(TRIM(A2))

Normalizes casing and spaces in one expression so lookups and COUNTIFS behave predictably.

Related functions

LEN proves invisible spaces exist; LOWER normalizes case before joins or lookups.

After cleanup, CONCAT / CONCATENATE produce stable composite keys.