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