Excel text functions — the complete guide
Text functions are the plumbing of every real workbook. Nine times out of ten, when data lands in Excel from another system, someone has to clean it — extract, split, join, standardize, reformat. This guide covers the 16 text functions you'll actually use, organized by job: extract, find, measure, clean, case-shift, join, modify, format. Every function has a worked example, and the last section shows how to compose them into the recipes that solve real problems.
Companion Workbook — 10 sheets, 112 live formulas
Every text function in this guide, plus a Real Patterns sheet with 7 composite recipes for email parsing, name splitting, phone standardization, and more.
⚡ Quick Answer
Excel's text functions fall into 8 categories: extract (LEFT, RIGHT, MID), find (FIND, SEARCH), measure (LEN), clean (TRIM, CLEAN), case (UPPER, LOWER, PROPER), join (CONCATENATE, TEXTJOIN, &), modify (SUBSTITUTE, REPLACE), and format (TEXT). Learning them individually is easy; learning how to compose them for real cleanup is where the value is.
📋 What's in this guide
- Extract: LEFT, RIGHT, MID
- Find: FIND vs SEARCH
- Measure: LEN
- Clean: TRIM and CLEAN
- Case: UPPER, LOWER, PROPER
- Join: CONCATENATE, TEXTJOIN, and &
- Modify: SUBSTITUTE and REPLACE
- Format: the TEXT function
- Real patterns: composing functions for real problems
- Common errors and fixes
- Frequently asked questions
Extract: LEFT, RIGHT, MID
The three positional extractors. Each takes a string and returns a chunk based on character position.
Extract country code from an order ID
=LEFT("USA-2026-00417", 3) → "USA"
LEFT counts characters from the start. Great when you know the fixed-width prefix — country codes, category codes, ticker symbols.
Extract record number from a suffix
=RIGHT("USA-2026-00417", 5) → "00417"
RIGHT counts from the end. Useful for record numbers, file extensions, or the last N characters of any pattern.
Extract the year from a structured ID
=MID("USA-2026-00417", 5, 4) → "2026"
MID(text, start, num_chars) — start at position 5, take 4 characters. The workhorse for extracting substrings from anywhere in the middle of a string.
If num_chars exceeds the text length, LEFT and RIGHT return the entire text — no error. So =LEFT("Hi", 10) returns "Hi". This is safe behavior you can rely on when combining with LEN.
Find: FIND vs SEARCH
Both return the position of one string inside another. The differences are case sensitivity and wildcard support.
| Aspect | FIND | SEARCH |
|---|---|---|
| Case sensitivity | Case-SENSITIVE | Case-INSENSITIVE |
| Wildcards (* ?) | Not supported | Supported |
| Not-found behavior | Returns #VALUE! | Returns #VALUE! |
| Best for | When case matters (rare) | Everything else (default) |
Locate the @ in an email address
=FIND("@", "john.smith@example.com") → 11
Returns the position of @ as a number. This is the essential building block for splitting emails into username and domain.
Case-insensitive search
=SEARCH("report", "Marketing Report Q4") → 11
SEARCH finds "Report" (capitalized in source) even though we searched for lowercase "report". FIND would fail here with #VALUE!.
Find the SECOND period in a dotted string
=FIND(".", "abc.def.ghi", 5) → 8
The third argument tells FIND (or SEARCH) where to start looking. Skipping to position 5 means we skip past the first period at position 4 and find the second period at position 8.
An unmatched FIND returns #VALUE!, which propagates through your entire formula. If your MID or LEFT depends on a FIND, wrap with IFERROR: =IFERROR(MID(A2, FIND("@", A2)+1, 100), "no email"). The error handling guide covers more patterns.
Measure: LEN
LEN counts every character — including spaces, punctuation, and hidden whitespace. It has one obvious use (length) and one non-obvious use (whitespace debugging).
Count characters
=LEN("Hello World") → 11
Ten letters plus one space equals eleven characters. LEN counts everything.
Detect if a cell has extra whitespace
=LEN(A2) - LEN(TRIM(A2))
If result > 0, the cell has hidden whitespace. This is the fastest way to find why a lookup is failing — a value like "Widget " (trailing space) looks identical to "Widget" but doesn't match.
Add a helper column =LEN(A2) next to any imported data column. Values that are longer than expected usually indicate hidden whitespace or non-printing characters. Combined with TRIM and CLEAN, this is your fastest data-quality check.
Clean: TRIM and CLEAN
Two functions, two jobs:
TRIM(text)
Removes leading and trailing spaces, and collapses runs of internal spaces to a single space.
=TRIM(" Alice Smith ") → "Alice Smith"
CLEAN(text)
Removes non-printing characters (ASCII codes 0-31 — tabs, line breaks, control characters). Leaves regular spaces alone.
=CLEAN("Data" & CHAR(9) & "Cleaned") → "DataCleaned"
The full-cleanup combo
=TRIM(CLEAN(A2))
This is the pattern to run on any imported data column. CLEAN first strips the tabs and line breaks; TRIM then normalizes spaces. Reverse the order and you might miss things — line breaks inside TRIM's target become weird spaces.
Standard data-import cleanup
Column A: Raw import (messy)
Column B: =TRIM(CLEAN(A2)) ← cleaned version
Column C: =LEN(A2)-LEN(B2) ← how many characters removed
Column C tells you which rows had cleanup applied. Sort or filter by column C to audit problematic rows first.
Case: UPPER, LOWER, PROPER
Three case-conversion functions. Each takes text and returns it in a different case.
UPPER(text) — ALL CAPS
=UPPER("hello world") → "HELLO WORLD"
Use for: normalizing product codes, country codes, matching keys for case-insensitive lookups.
LOWER(text) — all lowercase
=LOWER("USER@EXAMPLE.COM") → "user@example.com"
Use for: normalizing email addresses, URLs, deduplication keys.
PROPER(text) — Title Case Each Word
=PROPER("john q. smith") → "John Q. Smith"
Use for: cleaning inconsistent name entries, standardizing city/state names.
=PROPER("john from the CEO office") returns "John From The Ceo Office". PROPER just capitalizes first letters and lowercases the rest — it has no vocabulary. Fix known acronyms with SUBSTITUTE after PROPER: =SUBSTITUTE(PROPER(A2), "Ceo", "CEO"). For heavy acronym handling, Power Query gives you more control.
Join: CONCATENATE, TEXTJOIN, and &
Three ways to combine text pieces. Each has a place.
& operator — most common
Simplest way to join 2-4 pieces. Insert literal text (like spaces or delimiters) in quotes.
=A2 & " " & B2 → "Alice Chen"
=A2 & " " & B2 & " (" & C2 & ")" → "Alice Chen (Engineering)"
CONCATENATE(text1, text2, ...) — legacy function
Same effect as &, just written as a function. Kept for backward compatibility. No advantages over &.
=CONCATENATE(A2, " ", B2) → "Alice Chen"
TEXTJOIN(delimiter, ignore_empty, text_or_range, ...) — the modern winner
Best for joining a range with a consistent delimiter. Excel 2019+ or Microsoft 365.
=TEXTJOIN(", ", TRUE, A2:A10) → "Alice, Bob, Carol, David"
The second argument (TRUE) tells TEXTJOIN to skip empty cells. Set to FALSE to include them (produces "Alice, , Carol" if there's a blank).
Join with custom delimiter
=TEXTJOIN(" | ", TRUE, A2:A10) → "Alice | Bob | Carol | David"
Any delimiter works — pipes, tabs (CHAR(9)), line breaks (CHAR(10)), whatever you need. TEXTJOIN plus a range is orders of magnitude cleaner than chained & for many items.
For 2-4 pieces of text you're pasting together (like first + " " + last name), & is fastest to read. For joining an entire column of values with a delimiter, TEXTJOIN is dramatically cleaner. See CONCATENATE vs TEXTJOIN vs & for a deeper comparison.
Modify: SUBSTITUTE and REPLACE
Two functions for changing text. The key difference: SUBSTITUTE finds by content; REPLACE finds by position.
SUBSTITUTE(text, old_text, new_text, [instance])
Replaces all (or the Nth) occurrence of old_text with new_text.
=SUBSTITUTE("PRD-2026-USA", "-", " ") → "PRD 2026 USA" (all replaced)
=SUBSTITUTE("a-b-c-d", "-", " | ", 3) → "a-b-c | d" (only 3rd)
REPLACE(text, start_num, num_chars, new_text)
Replaces a fixed number of characters starting at a fixed position.
=REPLACE("555-1234", 1, 3, "999") → "999-1234" (chars 1-3 replaced with "999")
Remove all spaces from a string
=SUBSTITUTE("no spaces allowed", " ", "") → "nospacesallowed"
Replacing with an empty string removes the target. This is how you strip formatting characters from phone numbers, IDs, or codes.
Clean a phone number by removing multiple characters
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE("(555) 123-4567",
"(", ""), ")", ""), " ", ""), "-", "")
→ "5551234567"
Nested SUBSTITUTE strips each unwanted character in turn. Ugly to read, but effective. For heavy cleanup, consider Power Query instead.
SUBSTITUTE vs REPLACE — when to use which
| Situation | Use |
|---|---|
| Replace every occurrence of a specific string | SUBSTITUTE |
| Replace the Nth occurrence of a string | SUBSTITUTE with 4th argument |
| Replace a fixed-position substring (e.g., area code) | REPLACE |
| Clean out formatting characters | SUBSTITUTE with empty string |
| Mask credit card / SSN digits | REPLACE |
Format: the TEXT function
TEXT converts a number to formatted text using the same format codes as cell formatting. Critical when you need to display a number a specific way inside a concatenated string.
Number formats
| Format code | Input | Result |
|---|---|---|
"$#,##0" | 1234.567 | "$1,235" |
"$#,##0.00" | 1234.567 | "$1,234.57" |
"0%" | 0.156 | "16%" |
"0.00%" | 0.156 | "15.60%" |
"#,##0" | 1234567 | "1,234,567" |
"0.0E+00" | 1234567 | "1.2E+06" |
Date formats
| Format code | Result (for Sep 3, 2026) |
|---|---|
"yyyy-mm-dd" | "2026-09-03" |
"mm/dd/yyyy" | "09/03/2026" |
"dd-mmm-yyyy" | "03-Sep-2026" |
"mmmm d, yyyy" | "September 3, 2026" |
"dddd" | "Thursday" |
Concatenate a formatted number into a display string
="Total revenue: " & TEXT(B2, "$#,##0.00") → "Total revenue: $1,234.57"
Without TEXT, & would concatenate the raw number "1234.567" — no formatting. TEXT converts to a formatted string before joining. Essential for dashboard labels, email drafts, and dynamic report headers.
Real patterns: composing functions for real problems
Individual functions are easy. The value comes from composing them into recipes that solve specific problems. Here are the seven you'll use most.
Extract email domain
=MID(A2, FIND("@", A2) + 1, LEN(A2))
FIND locates the @, MID extracts from @+1 to the end. LEN as a safe upper bound — Excel simply returns whatever's left. Input "alice@company.com" → output "company.com".
Extract email username
=LEFT(A2, FIND("@", A2) - 1)
The mirror image of pattern 1. LEFT takes everything before the @. Input "alice@company.com" → output "alice".
Split full name into first and last
First: =LEFT(A2, FIND(" ", A2) - 1)
Last: =MID(A2, FIND(" ", A2) + 1, LEN(A2))
Same idea as email splitting, but on the space character. Input "Jennifer Lopez" → outputs "Jennifer" and "Lopez". For names with middle names, this extracts everything after the first space as "last name" — usually acceptable, but be aware.
Extract initials from a full name
=LEFT(A2, 1) & LEFT(MID(A2, FIND(" ", A2) + 1, LEN(A2)), 1)
LEFT gets the first initial. The inner MID+LEFT gets the first character after the space. Input "Jennifer Lopez" → output "JL".
Clean and standardize a messy name
=PROPER(TRIM(A2))
TRIM collapses whitespace, PROPER title-cases. Input " ALICE smith " → output "Alice Smith". The classic import cleanup for name fields.
Get company name from email (drop the .com)
=LEFT(MID(A2, FIND("@", A2) + 1, LEN(A2)),
FIND(".", MID(A2, FIND("@", A2) + 1, LEN(A2))) - 1)
Extract domain first (inner MID), then get everything before the first period (outer LEFT + FIND). Input "alice@company.com" → output "company". Nested but reliable.
Standardize a phone number to XXX-XXX-XXXX
Step 1 — digits only:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,
"(", ""), ")", ""), " ", ""), "-", ""), ".", "")
Step 2 — format from digits:
=LEFT(B2,3) & "-" & MID(B2,4,3) & "-" & RIGHT(B2,4)
Two-step process because doing it inline gets unreadable. Column B holds the digits-only version; column C reformats. Input "(555) 123.4567" → output "555-123-4567".
The companion workbook has all seven of these patterns live with editable inputs. Change the yellow-highlighted cell to test with your own data.
Common errors and fixes
Error 1: #VALUE! from FIND on missing text
=FIND("@", A2) returns #VALUE!. Formula looks correct.
The target string doesn't contain the search text. FIND (and SEARCH) return #VALUE! when they can't find a match. Wrap with IFERROR: =IFERROR(FIND("@", A2), "No email"). If your formula uses FIND inside MID or LEFT, wrap the WHOLE formula: =IFERROR(MID(A2, FIND("@",A2)+1, LEN(A2)), "n/a").
Error 2: #NUM! from negative MID length
A composite formula like =LEFT(A2, FIND(" ", A2) - 1) returns #NUM! or #VALUE!.
The value in A2 has no space (or no @, depending on your formula), so FIND fails. The subtraction becomes #VALUE! - 1 which propagates. Wrap with IFERROR, or validate the input first: =IF(ISNUMBER(FIND(" ", A2)), LEFT(A2, FIND(" ", A2) - 1), A2).
Error 3: TEXTJOIN not working in Excel 2016
=TEXTJOIN(...) returns #NAME? when opening in an older Excel version.
TEXTJOIN was added in Excel 2019. In Excel 2016 and earlier, it doesn't exist and returns #NAME?. Options: (1) use nested & concatenation instead, (2) use CONCATENATE for a fixed number of items, or (3) upgrade to Microsoft 365. For maximum compatibility, avoid TEXTJOIN in shared files where recipients might have older Excel.
Error 4: Numbers coming out with wrong precision from TEXT
=TEXT(0.1 + 0.2, "0.00") shows "0.30" but math with the same values shows something odd like 0.30000000000000004.
TEXT applies rounding based on your format code, which hides floating-point representation quirks. This is usually what you want for display. If you need actual rounding (not just display), use ROUND: =ROUND(0.1 + 0.2, 2) returns the number 0.3, and further math will work as expected.
Frequently asked questions
What's the difference between FIND and SEARCH in Excel?
FIND is case-sensitive; SEARCH is case-insensitive. FIND("Apple", "apple") returns #VALUE! because the case doesn't match. SEARCH("Apple", "apple") returns 1 — it treats them as equal. SEARCH also supports wildcards (* and ?); FIND does not. Use SEARCH by default unless case matters.
How do I split a full name into first and last name in Excel?
First name: =LEFT(A2, FIND(" ", A2) - 1). Last name: =MID(A2, FIND(" ", A2) + 1, LEN(A2)). FIND locates the space; LEFT grabs everything before it (first name); MID grabs everything after (last name). For names with middle names or multi-word last names, wrap with TRIM and adjust — see the companion workbook's Real Patterns sheet.
What does TRIM do in Excel?
TRIM removes leading and trailing spaces from text and collapses runs of internal spaces to a single space. So " Alice Smith " becomes "Alice Smith". It doesn't remove tabs, line breaks, or other non-printing characters — use CLEAN for those. Combine as =TRIM(CLEAN(A2)) for complete whitespace cleanup on imported data.
When should I use TEXTJOIN instead of CONCATENATE?
TEXTJOIN is better when: (1) you need to join a range of cells (like A1:A100), (2) you want to skip empty cells automatically, or (3) you need a consistent delimiter between items. CONCATENATE requires listing each cell individually and doesn't handle empty cells. TEXTJOIN was added in Excel 2019 — use it for all new work if you're on modern Excel or Microsoft 365.
How do I extract the domain from an email address?
Use =MID(A2, FIND("@", A2) + 1, LEN(A2)). FIND locates the @ symbol; MID extracts everything after it. LEN is used as a safe upper bound — Excel returns the rest of the string. For just the company name without .com, wrap the result with LEFT and another FIND for the period.
Why does PROPER capitalize 'CEO' as 'Ceo'?
PROPER capitalizes the first letter of every word and lowercases the rest. It doesn't know about acronyms, so "CEO" becomes "Ceo". There's no built-in fix — you'd need SUBSTITUTE to restore known acronyms manually: =SUBSTITUTE(PROPER(A2), "Ceo", "CEO"). For heavy acronym-preservation, apply PROPER selectively or use Power Query which has more control.
Do these text functions work in Google Sheets?
Yes, identically. LEFT, RIGHT, MID, FIND, SEARCH, LEN, TRIM, CLEAN, UPPER, LOWER, PROPER, CONCATENATE, SUBSTITUTE, REPLACE, and TEXT all work exactly the same in Google Sheets. TEXTJOIN also works. Google Sheets adds a few extras (like SPLIT and REGEXEXTRACT) that Excel doesn't have.
Grab the companion workbook
112 live formulas across 10 sheets — every function from this guide plus the 7 Real Patterns recipes.