That's the answer. The rest of this article is about when that answer isn't enough.
What the Menu Actually Does
The Trim whitespace tool removes spaces from the start and end of cell values, and collapses multiple internal spaces into one. So " Revenue " becomes "Revenue", and "Q1 Sales" becomes "Q1 Sales".
It's a destructive edit โ the original values are overwritten, not replaced by formulas. That's useful precisely because you don't want a formula column shadowing your real data forever. It's also dangerous if you haven't made a copy.
The tool only works on cells containing text. Numbers and dates are skipped.
Why Whitespace Breaks Spreadsheets
Invisible spaces cause more broken lookups than almost anything else. VLOOKUP, XLOOKUP, COUNTIF, SUMIF โ they all do exact character matching. A value of " Apple" (leading space) doesn't match "Apple". You get zeros where you expect numbers, #N/A where you expect results.
This is especially common after:
- CSV imports from accounting software (QuickBooks exports are notorious for this)
- Copy-paste from web pages, which often carry HTML whitespace artifacts
- API responses where string fields aren't sanitized before storage
- Form submissions that don't trim on the backend
In a 500-row P&L pulled from an ERP system, it's not unusual to find 30โ40% of text cells with at least one extra space. That's enough to silently corrupt SUMIF totals across an entire model.
Menu vs. TRIM() Function
| Data cleanup menu | TRIM() formula | |
|---|---|---|
| Edits in place | Yes | No โ output goes in separate cell |
| Works on numbers | No | No |
| Handles non-breaking spaces | No | No |
| Preserves original | No | Yes |
| Audit trail | No | Yes (formula visible) |
| Auto-updates on new data | No | Yes |
| Speed (1,000 rows) | ~2 seconds | Instant, but adds 1,000 formulas |
The menu is the right call for a one-time import cleanup. You ran a CSV in, there's junk in the name field, you select column A, click the menu, done. The formula is the right call when data arrives continuously and you need every incoming row sanitized automatically โ a live form feed, an IMPORTRANGE from another sheet.
Combining both is also valid: use TRIM() as an intermediary column that feeds into your analysis, then periodically paste-values-only back over the source if you want to clean things up permanently.
The Non-Breaking Space Problem
Here's what the menu misses: CHAR(160), the non-breaking space.
Web pages use non-breaking spaces ( in HTML) to prevent line breaks. When you copy data from a browser โ market data, Wikipedia tables, company directories โ those characters come along. They look identical to regular spaces in a spreadsheet cell. TRIM() doesn't touch them. The Data cleanup menu doesn't touch them. Your VLOOKUP fails and you have no idea why.
The fix is a SUBSTITUTE before TRIM:
=TRIM(SUBSTITUTE(A2, CHAR(160), " "))
This replaces every non-breaking space with a regular space, then TRIM strips the edges. If you're dealing with web-sourced data regularly, this formula is worth keeping around.
As of April 2026, Google Sheets hasn't added CHAR(160) handling to the Data cleanup menu. It's a known gap.
When to Run Cleanup Before Formulas
The order matters more than people expect. If you're building a model on top of imported data โ mapping cost centers, doing vendor reconciliation, running XLOOKUP across entity names โ run Trim whitespace before you write a single lookup formula. Debugging a broken SUMIF after the fact, trying to figure out whether the issue is the formula logic or invisible characters in the source data, is genuinely miserable.
The better workflow for any data import:
- Paste raw data into a staging sheet
- Run Data โ Data cleanup โ Trim whitespace
- Run SUBSTITUTE/TRIM on any columns sourced from the web
- Then build your formulas against the cleaned data
Thirty seconds of cleanup at the start saves an hour of debugging at the end.
Doing This at Scale with AI
For datasets with more complex cleanup needs โ inconsistent capitalization, mixed date formats, duplicate entries alongside whitespace issues โ you're looking at chaining multiple operations. That's where it gets tedious fast.
ModelMonkey handles multi-step data cleanup from a single instruction in the sidebar. Tell it "clean up the vendor name column โ strip spaces, fix capitalization, remove duplicates" and it applies the right combination of TRIM, PROPER, SUBSTITUTE, and deduplication logic directly to your sheet. Useful when the Data cleanup menu is only step one of five.
Try ModelMonkey free โ it works in both Google Sheets and Excel.