TRIM Function
TRIM cleans up text by removing leading, trailing, and extra spaces between words.
Syntax
Parameters
| Parameter | Description | Required |
|---|---|---|
| text | The text string to trim. | Required |
Basic Example
Remove extra spaces from text
=TRIM(" Hello World ")Removes leading and trailing spaces, leaving single spaces between words.
Advanced Examples
Example 1: Clean imported data
Data cleaningTrim whitespace from imported CSV data
=TRIM(A1)Example 2: Trim and uppercase for consistent lookups
Data matchingPrepare text for VLOOKUP by trimming and uppercasing
=UPPER(TRIM(A1))How TRIM Works
TRIM removes all spaces from the text except for single spaces between words. It removes leading, trailing, and consecutive internal spaces.
Important Notes & Limitations
TRIM only removes regular spaces (ASCII 32).
For non-breaking spaces (CHAR(160)), use SUBSTITUTE to replace them first.
Common Errors & Fixes
#VALUE!Invalid argumentFix: Ensure the argument is text or a cell reference.
Download Practice File
TRIM
trimPractice TRIM with Real Data
Download a sample CSV file with pre-populated data and practice exercises for the TRIM function. Works in both Excel and Google Sheets.
File format: CSV (comma-separated values) - opens in Excel, Google Sheets, and all spreadsheet apps
Related Tutorials
Convert Text to Number in Excel and Google Sheets
Convert text to number in Excel and Google Sheets with VALUE, multiplication and Paste Special. Handles currency symbols, hidden spaces and #VALUE! errors.
Remove Extra Spaces
TRIM, SUBSTITUTE and CLEAN remove extra spaces, non-breaking spaces and hidden characters in Excel and Google Sheets. Exact formulas plus lookup fixes.
VLOOKUP Not Returning Correct Value: Five Causes and Their Fixes
VLOOKUP not returning correct value? An omitted fourth argument, an unlocked table range, a wrong column index or duplicate keys explains almost every case.