Extract middle name from full name — Manipulating NAMES in Excel
If you need to get the middle name from a full name, and you already have the first and last names in separate cells, you can use a formula that extracts the middle name using the MID and LEN functions, with help from TRIM function.
Note: this is a pretty sloppy formula, but will work in many situations because TRIM cleans up extra spaces, including the case where there is no middle name. It won’t work if the names contain titles or suffixes that occur before the first name or after the last name.
Formula
=TRIM(MID(name,LEN(first)+1,LEN(name)-LEN(first&last)))
Explanation
How this formula works
Assuming you have a full name in column B, a first name in column C, and a last name in column D, you can use a formula that looks like this:
=TRIM(MID(B5,LEN(C5)+1,LEN(B5)-LEN(C5&D5)))
At the core, the MID function extracts text from the full name starting at 1 character after the length of the first name. The total characters extracted is equal to the length of the full name minus the length of the first and last names put together.
By design, the formula extracts all text between the first name and the last name, including extra space characters, and then relies on the brute force of TRIM to clean everything up in the end:
1. When there is a middle name. MID gets the middle name (with space on either side) and TRIM removes the extra space.
2. When there is more than one middle name, MID gets all middle names (with space on either side) and trim strips the extra space characters.
3. When there is no middle name, it MID returns a space character, which is removed by TRIM, leaving nothing.