Excel functions / Text

Extract the last word

Pull out the last word of some text, such as a surname, however many words come first.

How it works

In Microsoft 365, TEXTAFTER with an instance number of -1 splits at the last space: =TEXTAFTER(A2," ",-1). It works for "Nina Shah" and "Mary Ann Lee" alike.

In older versions there is a well-known trick: replace every space with lots of spaces, take a big slice from the right, and trim it: =TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100)).

Example

D4=TEXTAFTER(A4," ",-1)
ABCD
1NameEmail
2Nina Shahnina.shah@example.com
3Omar Reidomar@example.com
4Mary Ann Leemary.lee@example.comLee
5

Result: Lee. Mary Ann Lee has two spaces. -1 splits at the last one.

Tips

Practise Extract the last word

Try it yourself in a real spreadsheet, with instant feedback on every answer.

Start the exercise

Related