Skip to content

Excel function guide · Text

TRIM function in Excel

TRIM removes spaces from the start and end of text and reduces any run of spaces between words to a single space. It's the first fix when a lookup returns #N/A or a count looks too low on imported data.

Syntax

=TRIM(text)
ArgumentRequired?What it means
textRequiredThe text or cell to clean.

TRIM examples

Every example uses this small table. The results are what Excel shows in the cell.

AB
1Raw nameTeam
2··Sara·AhmedSales
3Tom···Baker·Finance
4lina·COSTAHR
5Yusuf·Demir··Sales

· marks a space, so you can see the extra ones.

  1. 1. Leading spaces

    =TRIM(A2)

    Result: Sara Ahmed

    The two spaces before Sara are removed.

  2. 2. Spaces in the middle and at the end

    =TRIM(A3)

    Result: Tom Baker

    Three spaces between the names become one, and the trailing space goes.

  3. 3. Clean and capitalise

    =PROPER(TRIM(A4))

    Result: Lina Costa

    TRIM runs first, then PROPER capitalises the first letter of each word.

Try it now

Practise TRIM in a live sheet.

Type each formula yourself. Answers are checked by the same engine as the full course. No account needed.

Try it · TRIM
0 XP
C2
A
B
C
D
E
F
1
Raw name
Team
Clean name
Proper case
2
Sara Ahmed
Sales
3
Tom Baker
Finance
4
lina COSTA
HR
5
Yusuf Demir
Sales
6
7
8
Double-click or start typing to edit

Step 1 of 3

In C2, remove the extra spaces from the name in A2 with TRIM.

Common TRIM mistakes

Practise this in Excel Quest

Clean a customer list Members

Course 7 · Text & Data Cleaning · 12 min

Standardise names, emails, postcodes and notes, then spot duplicates that only differed by case and spacing.

This lesson is included in Formula Quest memberships. A free account starts you on the free lessons of the Excel Quest curriculum.

Related functions

All Excel function guides