When names are written as First Last, the first name is everything before the first space: =LEFT(A2, FIND(" ", A2)-1). In Microsoft 365 the same is simply =TEXTBEFORE(A2, " "). Add TRIM first if the data has extra spaces.
{"cells": {"A1": "Full name", "A2": "Anna Petrova", "A3": "Ivan Georgiev", "A4": "Maria Ivanova Dimitrova", "A5": "Elena Stoyanova", "A8": "Surname, First", "A9": "Petrova, Anna", "B1": "First name", "B2": "=LEFT(A2,FIND(\" \",A2)-1)", "B3": "=LEFT(A3,FIND(\" \",A3)-1)", "B4": "=LEFT(A4,FIND(\" \",A4)-1)", "B5": "=LEFT(A5,FIND(\" \",A5)-1)", "B8": "First name", "B9": "=TRIM(MID(A9,FIND(\",\",A9)+1,99))", "C1": "With TEXTBEFORE", "C2": "=TEXTBEFORE(A2,\" \")", "C3": "=TEXTBEFORE(A3,\" \")", "C4": "=TEXTBEFORE(A4,\" \")", "C5": "=TEXTBEFORE(A5,\" \")"}, "focus": "B2", "note": "Type your own name in A2."}
LEFT and FIND (every version)
FIND gives the position of the space; LEFT takes everything before it.
=LEFT(A2, FIND(" ", A2)-1)Anna from "Anna Petrova".=IFERROR(LEFT(A2, FIND(" ", A2)-1), A2)Returns the whole cell when there's no space.TEXTBEFORE (Microsoft 365)
One readable function. The 6th argument is what to return if there's no space.
=TEXTBEFORE(A2, " ")Everything before the first space.=TEXTBEFORE(TRIM(A2), " ", , , , A2)Safe for single names and extra spaces.Surname, First name
Find the comma instead and take what comes after it.
=TRIM(MID(A2, FIND(",", A2)+1, 99))Anna from "Petrova, Anna".=TEXTAFTER(A2, ", ")The same in Microsoft 365.Common mistakes
- #VALUE! error
- The cell has no space, so FIND fails. Wrap the formula in IFERROR.
- A space is left at the start
- The data has leading spaces. Use
TRIM(A2)inside the formula.
Frequently asked questions
How do I get the last name?
Can Excel do this without a formula?
Yes: type the first result by hand in the next column and press Ctrl+E (Flash Fill).
How do I capitalise the result?
Wrap it in PROPER: =PROPER(LEFT(A2, FIND(" ", A2)-1)).