How to remove the middle name from a full name in Excel
Excel formula
=TEXTBEFORE(A2," ")&" "&TEXTAFTER(A2," ",-1)Join the first word and the last word: =TEXTBEFORE(A2," ")&" "&TEXTAFTER(A2," ",-1). Names with no middle name come back unchanged.
- Result on the example
- one result per row in
B2, filled down toB7 - Works in
- Microsoft 365 only
- Google Sheets
- Different formula, see below
See it work
The formula is already in B2, filled down to B7. Change any input and the result updates, or edit the formula to experiment.
How it works
TEXTBEFORE returns the text before the first space (the first name) and TEXTAFTER with -1 returns the text after the last space (the last name). Whatever sits between them, a middle name, an initial or nothing, is dropped.
The Google Sheets pattern only matches names with something between two spaces, so two-part names pass through untouched.
=TEXTBEFORE(A2," ")&" "&TEXTAFTER(A2," ",-1)Result"Mary Smith"
A2"Mary Ann Smith"The value in A2.
TEXTBEFORE(A2," ")"Mary"TEXTBEFORE: Text before a delimiter.- text
A2"Mary Ann Smith" - delimiter
" "
- text
TEXTBEFORE(A2," ")&" ""Mary "The & operator joins as text.
-1-1Makes the value negative.
TEXTAFTER(A2," ",-1)"Smith"TEXTAFTER: Text after a delimiter.- text
A2"Mary Ann Smith" - delimiter
" " - instance_num
-1-1
- text
TEXTBEFORE(A2," ")&" "&TEXTAFTER(A2," ",-1)"Mary Smith"The & operator joins as text.
In Google Sheets
Google Sheets needs a different formula: =REGEXREPLACE(A2,"^(\S+) .* (\S+)$","$1 $2"). On the same data it gives the same result. Here it is running in Google Sheets mode.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =LEFT(A2,FIND(" ",A2))&TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100)) | Mary Smith, Maria Lopez, John Jones… | Works in every version: LEFT keeps the first name and its space, and the TRIM(RIGHT(SUBSTITUTE())) part returns the last word. |
Common mistakes
- A single-word name returns #N/A. Wrap it:
=IFERROR(TEXTBEFORE(A2," ")&" "&TEXTAFTER(A2," ",-1),A2). - Two-word first names like "Mary Ann" lose their second half. If that matters, keep the original column and review those rows.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Remove the middle name from a full name
B2, remove the middle name or initial so only the first and last names remain, and fill down to B7.Questions
How do I keep the middle initial instead of dropping it?
For three-part names: =TEXTBEFORE(A2," ")&" "&MID(A2,FIND(" ",A2)+1,1)&". "&TEXTAFTER(A2," ",-1) gives "Mary A. Smith".
How do I extract the middle name instead?
Use =TEXTBEFORE(TEXTAFTER(A2," ")," ",-1,,,"").
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.