TRIM
TextbeginnerTRIM 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
=TRIM(text)Parameters
textThe text string to clean.? = optional parameter
Worked Example
A vendor name was entered as ' Cloudline Software ' with extra spaces.
| Row numbers | |
|---|---|
| Header row | raw_vendor_name |
| 2 | Cloudline Software |
| 3 | Apex Office Supply |
| 4 | Summit Consulting Group |
| 5 | Meridian Travel Co. |
| 6 | Forge & Frame Creative |
Formula
=TRIM(A2)Result
Cloudline SoftwareTRIM 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
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 numbers | A | B |
|---|---|---|
| Header row | ||
| 2 | INV-1001 | Cloudline Software |
| 3 | INV-1002 | Apex Office Supply |
| 4 | INV-1003 | Summit Consulting Group |
| 5 | INV-1004 | Meridian Travel Co. |
| 6 | INV-1005 | Forge & Frame Creative |
| 7 | INV-1006 | NovaTech Solutions |
| 8 | INV-1007 | Atlas Hardware Co. |
| 9 | INV-1008 | Clearview Data Systems |
| 10 | INV-1009 | Redstone Marketing |
| 11 | INV-1010 | Keystone Legal Advisors |
| 12 |
Scroll to explore the table, then sort or filter by column as needed.
Hints
Your Answer
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 numbers | A | B |
|---|---|---|
| Header row | ||
| 2 | INV-1001 | Cloudline Software |
| 3 | INV-1002 | Apex Office Supply |
| 4 | INV-1003 | Summit Consulting Group |
| 5 | INV-1004 | Meridian Travel Co. |
| 6 | INV-1005 | Forge & Frame Creative |
| 7 | INV-1006 | NovaTech Solutions |
| 8 | INV-1007 | Atlas Hardware Co. |
| 9 | INV-1008 | Clearview Data Systems |
| 10 | INV-1009 | Redstone Marketing |
| 11 | INV-1010 | Keystone Legal Advisors |
| 12 | INV-1011 | Cloudline Software |
| 13 | INV-1012 | Basecamp Events |
| 14 | INV-1013 | Apex Office Supply |
| 15 | INV-1014 | BrightPath Analytics |
| 16 | INV-1015 | Meridian Travel Co. |
| 17 | INV-1016 | Clearview Data Systems |
| 18 | INV-1017 | Apex Office Supply |
| 19 | INV-1018 | Summit Consulting Group |
| 20 | INV-1019 | Cloudline Software |
| 21 | INV-1020 | Atlas 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.