Splitting a two-word name like “Priya Nair” into First Name and Surname is easy. The real headache starts when your customer or HR list mixes two-word names and three-word names like “Rohan Kumar Sharma”—suddenly basic formulas pull the middle name into the surname column or display #VALUE! errors.
Below are reliable formulas to separate First Name, Middle Name, and Surname (Last Name) cleanly in both Excel 365 and older Excel versions.
Sample Dataset
Assume your full names start in cell A2 (for example: Rohan Kumar Sharma in A2, Priya Nair in A3, and Amit Raj Verma in A4).
Method 1: Middle Name & Surname Formulas (All Excel Versions)
1. Extract First Name
=IFERROR(LEFT(TRIM(A2), FIND(" ", TRIM(A2))-1), TRIM(A2))
2. Middle Name Formula in Excel (Blank If No Middle Name)
=IFERROR(TRIM(MID(TRIM(A2), FIND(" ", TRIM(A2))+1, FIND(" ", TRIM(A2), FIND(" ", TRIM(A2))+1) - FIND(" ", TRIM(A2)) - 1)), "")
How it works: It finds the positions of the first and second spaces, then extracts the text in between. If the cell only has two words (like Priya Nair), IFERROR returns a clean empty cell "".
3. Extract Surname (Always Grabs the Final Word)
=IFERROR(TRIM(RIGHT(SUBSTITUTE(TRIM(A2), " ", REPT(" ", 100)), 100)), TRIM(A2))
Why this works: Replacing each space with 100 spaces pushes the surname to the far right, so RIGHT(..., 100) + TRIM accurately captures the surname whether a person has 2, 3, or 4 names.
Method 2: Excel 365 Short Formulas (TEXTBEFORE & TEXTAFTER)
- First Name:
=TEXTBEFORE(TRIM(A2), " ", 1, , , TRIM(A2)) - Middle Name:
=IFERROR(TEXTBEFORE(TEXTAFTER(TRIM(A2), " ", 1), " ", 1), "") - Surname:
=TEXTAFTER(TRIM(A2), " ", -1, , , "")
Related Name Splitting Guides
Also read Excel Formula to Separate First and Last Name Into Two Columns and Split First, Middle & Last Name Using Formula and Flash Fill. Need help cleaning large spreadsheets? Visit our Data Entry & Excel Cleaning Service.
Frequently Asked Questions
How do I separate Surname, First Name, and Middle Name in Excel when Surname comes first?
If formatted as Sharma Rohan Kumar, the first formula grabs Sharma (Surname), the middle formula grabs Rohan (First Name), and the last-word formula grabs Kumar (Middle Name).
Do extra spaces break the middle name formula?
No, wrapping A2 inside TRIM(A2) removes accidental double spaces before extracting each word.
[…] some rows contain 3-word names, check our How to Extract Middle Name and Surname in Excel guide and our complete Split First, Middle & Last Name in Excel tutorial. Need bulk list […]