Back to functions
Text2026-03-148 related articles

TRIM Function in Excel

Remove extra spaces from text while leaving single spaces between words.

Syntax

TRIM(text)

Arguments

text

Required

The text string or cell reference to clean.

What it returns

Returns text with leading, trailing, and repeated internal spaces reduced.

What TRIM does

TRIM cleans spacing problems in text. It removes leading spaces, trailing spaces, and repeated spaces between words, leaving only single internal spaces.

That is especially helpful before lookups, comparisons, imports, and deduplication.

Practical examples

Clean imported names or codes

=TRIM(A2)

Use this when a pasted or imported field contains spaces that are not visible at first glance.

Stabilize lookups

=VLOOKUP(TRIM(E2),$A$2:$C$20,3,FALSE)

Wrapping the lookup value with TRIM can prevent failed matches caused by stray spaces.

Common mistakes and notes

TRIM does not fix every invisible character

It handles regular spaces well, but some imported data contains nonbreaking spaces or other characters that may need a more advanced cleanup step.

Clean both sides when necessary

If a lookup still fails after trimming the lookup value, the source column may need cleanup too.

Related functions

Related articles

Deep dives, troubleshooting guides, and practical examples that use TRIM.

AI in ExcelFormulas
2026-02-26

How to Use =COPILOT in Excel

Learn how to use the =COPILOT function in Excel, what kinds of prompts work best in cells, and where this feature still needs careful review....

#ai#copilot#formulas#microsoft-365
3 min read
Read Article
AI in Excel
2026-02-05

How to Upload an Excel File to ChatGPT and Analyze It Safely

Learn how to upload an Excel file to ChatGPT safely, what kinds of workbook questions it handles well, and what you still need to verify manually....

#ai#chatgpt#file-analysis#privacy#cleanup
4 min read
Read Article
AI in ExcelFormulas
2026-01-22

Can AI Fix Broken Excel Formulas? Real Tests With VLOOKUP, XLOOKUP, and SUMIFS

I tested whether AI can fix broken Excel formulas in real scenarios involving VLOOKUP, XLOOKUP-style logic, and SUMIFS errors caused by dirty data....

#ai#formulas#troubleshooting#benchmark#vlookup
4 min read
Read Article
AI in ExcelTroubleshooting
2025-12-04

Why Copilot Is Not Working in Excel: Common Fixes and Requirements

Fix the most common reasons Copilot is not working in Excel, including table setup problems, licensing issues, platform limits, and messy workbook structure....

#ai#copilot#troubleshooting#microsoft-365
4 min read
Read Article
AI in Excel
2025-11-20

How to Use Copilot in Excel for Formulas, Analysis, and Cleanup

Learn how to use Copilot in Excel for real workbook tasks such as formula writing, data cleanup, and quick analysis without trusting the first answer blindly....

#ai#copilot#formulas#cleanup#data-analysis
4 min read
Read Article
AI in ExcelAdvanced
2025-11-14

AI in Excel: Practical Guide to Copilot, ChatGPT, Claude, and Gemini

Learn how to use AI in Excel with Copilot, ChatGPT, Claude, and Gemini. Compare strengths, limitations, use cases, and how to verify AI-generated formulas, analysis, and automation....

#ai#copilot#chatgpt#claude#gemini#data-analysis#automation
16 min read
Read Article
Formulas
2023-10-09

VLOOKUP Not Working with Text Values: 6 Fixes You Need

Fix your VLOOKUP not working with text issue using our troubleshooting tips. Don't let #N/A or #VALUE errors stop you from getting accurate results....

#functions#lookup
11 min read
Read Article
FormulasIntermediate
2010-12-29

The TRIM Function in Excel and VBA

The Excel TRIM Function removes all spaces from text except single spaces between words. The VBA TRIM Function removes leading and trailing spaces....

1 min read
Read Article

Official documentation