Excel 365's text (string) functions let you clean, split, join and reshape text without retyping it: you pull a first name out of a full name, strip stray spaces from imported data, join columns into a mailing label, or break an address into pieces. The most useful modern additions are TEXTBEFORE, TEXTAFTER, TEXTSPLIT, CONCAT and TEXTJOIN, but the classics (LEFT, RIGHT, MID, FIND, SEARCH, LEN, SUBSTITUTE, TRIM, UPPER, LOWER, PROPER) still do most of the everyday work and every one of them is still supported. Nothing needs installing — every function covered here ships with Excel 365 on Windows, Mac and the web app — but be aware that the newer text functions are not available in Excel 2019 or older, so if you share the file with someone on an older version, those cells can show #NAME? or #VALUE! errors for them.
What You'll Need
- A Microsoft 365 subscription with the Excel desktop app or the free Excel web app, signed in with your Microsoft account.
- A worksheet with some text data you want to work on — a full name, an email, a SKU, a list with duplicates, anything.
- Enough comfort to type a formula starting with = and press Enter.
- If you plan to hand the file to someone else: knowledge of which Excel version they run, because the newer text functions are Excel 365 only.
Step-by-Step
- Work on a safe copy. Select the column header, copy it, and paste it into a new column beside your data. String formulas are the easiest way to overwrite source data by accident, so keep the original intact until the formula is proven.
- Start every formula with the equals sign. Click the first cell beside your data, type for example
=LEFT(A2,5)and press Enter. Formulas always begin with=; if you type a formula and the cell shows the text instead of a result, the equals sign is missing or the cell's format is set to Text (fix via the Home tab's number format dropdown, set it to General, then re-enter the formula). - Pull a fixed number of characters with LEFT, RIGHT and MID. LEFT returns characters from the start:
=LEFT(A2,3)on "ABC-1234" gives "ABC". RIGHT returns from the end:=RIGHT(A2,4)gives "1234". MID takes from the middle, with a starting position and a count:=MID(A2,5,2)gives "12". The position counts characters, so position 5 in "ABC-1234" is the dash. - Find the split point with SEARCH or FIND. Hard-coded positions break when the text changes length. SEARCH and FIND give you the position of a character instead:
=FIND("-",A2)returns 4 for "ABC-1234". The difference matters: FIND is case-sensitive and does not accept wildcards; SEARCH is not case-sensitive and accepts wildcards like?and*. If the character is missing, both return #VALUE! — so wrap them in IFERROR (step 10). - Use LEN to measure and TRIM to clean.
=LEN(A2)counts characters including spaces.=TRIM(A2)removes leading and trailing spaces and collapses runs of internal spaces to one — this is the single most valuable formula on data pasted from a website or exported report, because a stray space breaks lookup and comparison formulas silently. Note that TRIM does not remove the non-breaking space character (CHAR(160)) often found in web copy; for that use=TRIM(SUBSTITUTE(A2,CHAR(160)," ")). - Change case with UPPER, LOWER and PROPER. UPPER makes everything capitals, LOWER makes it all lowercase, and PROPER capitalises the first letter of each word. Use LOWER before an email comparison, because email addresses are case-insensitive but Excel's IF and lookup comparisons are not, so "Sam@Example.com" and "sam@example.com" look different to Excel. PROPER is imperfect on names like "McDonald" or "O'Neil" — correct those by hand.
- Replace text with SUBSTITUTE and cut it out with REPLACE.
=SUBSTITUTE(A2,"-","")deletes every dash, turning "ABC-1234" into "ABC1234". REPLACE works by position instead:=REPLACE(A2,1,3,"XYZ")swaps the first three characters for XYZ. SUBSTITUTE has an optional fourth argument for which occurrence to replace, handy for changing only the second comma in a list. - Join text with CONCAT and TEXTJOIN.
=CONCAT(A2,B2)glues cells together with no separator.=CONCAT(A2," ",B2)adds a space. TEXTJOIN is the flexible one:=TEXTJOIN(", ",TRUE,A2:C2)joins a range with a comma and space, and the TRUE tells Excel to ignore empty cells. That last point is the reason to prefer TEXTJOIN over CONCAT for ranges — CONCAT just squeezes everything together with no separators, so it produces messy output. - Split text with TEXTBEFORE, TEXTAFTER and TEXTSPLIT.
=TEXTBEFORE(A2,"@")returns everything before the at sign of an email;=TEXTAFTER(A2,"@")returns the domain. Both take an optional instance number, so=TEXTBEFORE(A2," ",2)finds the text before the second space. TEXTSPLIT goes further and spills the pieces into neighbouring cells:=TEXTSPLIT(A2," ")on "John Smith Junior" fills three cells. Make sure the cells to the right are empty, or you get a #SPILL! error. - Protect formulas from errors with IFERROR. Wrap any formula that can fail:
=IFERROR(TEXTBEFORE(A2,"@"),"No email"). This turns #VALUE! and #N/A into a plain label, so a report does not fill with error codes. Only do this where the absence genuinely means "not found" — don't hide real mistakes by wrapping the entire workbook. - Fill down and check the results. Drag the fill handle from the bottom-right corner of the first formula cell, or double-click it to fill to the end of the adjacent data. Then spot-check a handful of rows by eye and add a validation column such as
=LEN(original)=LEN(cleaned)+LEN(removed)or a simple comparison against a known correct value. When you're satisfied, copy the formula column and use Paste Special > Values to turn the results into plain text, so the file stays readable to anyone else and can be deleted down to its source if needed.
Common Mistakes
Hard-coding positions. LEFT(A2,5) is fine for a fixed-width code but breaks the moment a value gets longer. Where the text has a delimiter, use SEARCH or FIND to locate it and build the count from there, e.g. =LEFT(A2,FIND("-",A2)-1).
Forgetting spaces count as characters. LEN("a b") is 3, not 2. Any formula that subtracts 1 to drop a delimiter has to account for the space around it too.
Confusing SUBSTITUTE with REPLACE. SUBSTITUTE looks for text; REPLACE works by position. Using REPLACE to remove every dash fails because it only replaces one occurrence at a fixed spot.
Assuming TRIM removes every stray space. It doesn't touch non-breaking spaces, which are common in web-pasted data and produce the classic "the values look identical but don't match" puzzle. Use the CHAR(160) SUBSTITUTE shown above.
Leaving spill ranges blocked. TEXTSPLIT and other dynamic array formulas need empty cells to their right and below. If they're blocked you get #SPILL!, not a wrong answer.
Sending files containing new functions to older Excel. TEXTBEFORE, TEXTAFTER, TEXTSPLIT and TEXTJOIN don't exist in Excel 2019 and earlier or in some other spreadsheet apps. If recipients use those, paste the results as values before sharing.
Tips
Name your columns in row 1 and keep formulas in a clearly labelled helper column such as "Clean Name" rather than overwriting data. Use Table formatting (Insert > Table) so formulas fill automatically as new rows arrive. Chain functions for common clean-ups: =PROPER(TRIM(A2)) gives tidy, capitalised names in one step. Use =TEXT(A2,"dd-mm-yyyy") style formatting only on real dates; for text, format strings are limited to string functions. If you are on Windows, F4 repeats the last action and Ctrl+Enter fills every selected cell with the same formula — useful for bulk edits. Finally, keep a small test sheet with odd values (empty cells, multiple spaces, hyphens, accented letters) so you can confirm a formula handles the mess before running it across thousands of rows.
Troubleshooting
Cell shows the formula text, not a result. The cell is formatted as Text or the equals sign is missing. Change the format to General and re-enter, or press Ctrl+` (the key left of 1) to check whether the sheet is in Show Formulas view.
#VALUE! error. Usually a FIND or SEARCH failed because the delimiter isn't there, or a numeric function received text. Wrap the lookup in IFERROR and inspect a failing row with LEN to see exactly what characters are present.
#NAME? error. Either the function name is misspelled or the function doesn't exist in that Excel version — the newer text functions are a frequent cause when a file is opened elsewhere. Check the version via File > Account, then replace with LEFT/RIGHT/MID equivalents if needed.
#SPILL! error. A dynamic array formula has no room to expand. Clear the cells to the right and below, or move the formula to a column with space.
Results look right but lookups still fail. Almost always hidden spaces or non-breaking spaces. Run both TRIM and the CHAR(160) SUBSTITUTE, then re-test the comparison.
Formula copied down shows the same value everywhere. The references are absolute ($A$2) when they should be relative. Remove the dollar signs, or vice versa depending on intent.
Not going to plan after all that? Undo with Ctrl+Z on Windows or Cmd+Z on Mac, restore the untouched source column, and rebuild the formula one piece at a time in separate test cells until the failing part is obvious.
Frequently Asked Questions
Do I need a Microsoft 365 subscription for these functions?
The classic text functions work in any Excel version. TEXTBEFORE, TEXTAFTER, TEXTSPLIT and TEXTJOIN are Microsoft 365 only, and the Excel web app follows the 365 function set.
What is the difference between FIND and SEARCH?
FIND is case-sensitive and doesn't accept wildcards; SEARCH ignores case and does. Use SEARCH when the text might vary in capitalisation, FIND when the exact case matters.
Can I split a full name into first and last names?
Yes: =TEXTBEFORE(A2," ") for the first name and =TEXTAFTER(A2," ") for the rest. Names with middle names or hyphens need a quick manual check.
Why does TRIM seem to do nothing?
The spaces are probably non-breaking spaces from a web page or export. Substitute CHAR(160) with a normal space first, then apply TRIM.
How do I join text with a line break?
Use CHAR(10) in the separator and turn on Wrap Text for the cell: =A2&CHAR(10)&B2.
Why do I get #SPILL! with TEXTSPLIT?
The formula needs empty space to output its pieces. Clear the cells to the right and below the formula, or move it.