TRIM

Textbeginner

TRIM cleans up text by removing leading spaces, trailing spaces, and reducing multiple consecutive spaces to one. It's a critical data cleaning formula — messy data from imports, copy-pastes, or manual entry often has hidden spaces that break lookups and comparisons.

Syntax

Excel:=TRIM(text)
Google Sheets: Same syntax

Parameters

textThe text string to clean.

? = optional parameter

Worked Example

A vendor name was entered as ' Cloudline Software ' with extra spaces.

Row numbers
Header rowraw_vendor_name
2 Cloudline Software
3Apex Office Supply
4 Summit Consulting Group
5Meridian Travel Co.
6 Forge & Frame Creative

Formula

=TRIM(A2)

Result

Cloudline Software

TRIM cleans the text in A2 by removing the leading and trailing spaces and collapsing the double space in the middle to a single space. In this sample, that turns A2 into 'Cloudline Software'.

Practice Exercises

2 exercises - work through each one using the data table below

Exercise 1 of 2beginner
#TRIM-001

Question

A vendor name was imported with extra spaces: ' Apex Office Supply '. After running =TRIM(" Apex Office Supply "), is the result still 'Apex Office Supply' with extra spaces? Answer 'Yes' or 'No'.

Dataset

Showing rows 1-10

Download CSV
Row numbersAB
Header row
2INV-1001Cloudline Software
3INV-1002Apex Office Supply
4INV-1003Summit Consulting Group
5INV-1004Meridian Travel Co.
6INV-1005Forge & Frame Creative
7INV-1006NovaTech Solutions
8INV-1007Atlas Hardware Co.
9INV-1008Clearview Data Systems
10INV-1009Redstone Marketing
11INV-1010Keystone Legal Advisors
12

Scroll to explore the table, then sort or filter by column as needed.

Hints

Your Answer

Exercise 2 of 2beginner
#TRIM-002

Question

You've run TRIM on every vendor name in the dataset and found that all names are already free of leading, trailing, and extra internal spaces. How would you describe the whitespace state of the vendor names: 'Dirty' or 'Clean'?

Dataset

Showing rows 1-20

Download CSV
Row numbersAB
Header row
2INV-1001Cloudline Software
3INV-1002Apex Office Supply
4INV-1003Summit Consulting Group
5INV-1004Meridian Travel Co.
6INV-1005Forge & Frame Creative
7INV-1006NovaTech Solutions
8INV-1007Atlas Hardware Co.
9INV-1008Clearview Data Systems
10INV-1009Redstone Marketing
11INV-1010Keystone Legal Advisors
12INV-1011Cloudline Software
13INV-1012Basecamp Events
14INV-1013Apex Office Supply
15INV-1014BrightPath Analytics
16INV-1015Meridian Travel Co.
17INV-1016Clearview Data Systems
18INV-1017Apex Office Supply
19INV-1018Summit Consulting Group
20INV-1019Cloudline Software
21INV-1020Atlas Hardware Co.
22

Scroll to explore the table, then sort or filter by column as needed.

Hints

Your Answer

Want more practice?

Test Me mode randomizes exercises across all formulas without telling you which formula to use.

Try Test Me ->