ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Text
  3. Extract the Last Word From a Cell in Excel

Extract the Last Word From a Cell in Excel

By ExcelReady Team·Updated November 2, 2026·7 min read

The short answer

To extract the last word from a cell in Microsoft 365 or Excel 2024, use =TEXTAFTER(A2," ",-1). The -1 tells Excel to start from the last space instead of the first. In older versions, use =TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100)), which works for any number of words.

Key takeaways

  • =TEXTAFTER(A2," ",-1) returns the text after the last space, which is the last word.
  • TEXTAFTER needs Microsoft 365 or Excel 2024. In older Excel, use TRIM, RIGHT, SUBSTITUTE and REPT.
  • RIGHT with FIND only works when the cell has exactly two words, because FIND finds the first space.
  • Wrap the text in TRIM first if cells might have extra or trailing spaces.
On this page+
  1. The example data
  2. The quick way: TEXTAFTER with -1
  3. The classic way: RIGHT, SUBSTITUTE and TRIM
  4. Why RIGHT and FIND only work for two words
  5. Handle cells with one word or extra spaces
  6. Get everything except the last word
  7. When the last word is a number
  8. Flash Fill: the no-formula option
  9. Practise it

To extract the last word from a cell in Excel, find the last space and take everything after it. In Microsoft 365 or Excel 2024, =TEXTAFTER(A2," ",-1) does this in one step. In older versions, a formula built from RIGHT, SUBSTITUTE and TRIM does the same job. This guide shows both, with the errors you are likely to hit, for anyone splitting last names, cities or product codes out of a text column.

The example data#

All the examples use this list of full names in column A. Some names have two words, some have three or four, so a good formula must work for all of them.

AB
1Full nameLast name
2Maria Lopez GarciaGarcia
3Tom BakerBaker
4Aisha BelloBello
5Jean Paul MartinMartin
6Kenji SatoSato
7Ana Sofia de SouzaSouza

Column B shows the result we want. The "last word" is the text after the last space in the cell.

The quick way: TEXTAFTER with -1#

TEXTAFTER returns the text that comes after a delimiter. A delimiter is the character that separates the parts, here a space. The syntax is:

Excel formula
=TEXTAFTER(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])

The third argument, instance_num, says which space to use. 1 means the first space, 2 the second, and a negative number counts from the end. So -1 means the last space:

Excel formula
=TEXTAFTER(A2," ",-1)

For Maria Lopez Garcia, the result is Garcia. Fill it down (Windows: Ctrl+D; Mac: ⌘D) and every row returns the right last name, whether the name has two words or four.

TEXTAFTER and its partner TEXTBEFORE need Microsoft 365 or Excel 2024. In Excel 2021 or earlier they show #NAME?. The TEXTBEFORE and TEXTAFTER lesson walks through both functions step by step.

The classic way: RIGHT, SUBSTITUTE and TRIM#

In any version of Excel, this formula returns the last word, however many words the cell has:

Excel formula
=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100))

It looks strange, but each part has one job:

  1. REPT(" ",100) makes a block of 100 spaces.
  2. SUBSTITUTE(A2," ",...) replaces every single space in the name with that block of 100 spaces. The words are now far apart.
  3. RIGHT(...,100) takes the last 100 characters. Because the words are so far apart, those 100 characters hold only the last word plus a lot of spaces.
  4. TRIM(...) removes the extra spaces and leaves Garcia.

The only limit is that the last word must be shorter than 100 characters, which is true for names, cities and most codes. A nice side effect: if the cell has no space at all, the formula returns the whole cell instead of an error. The RIGHT function guide explains the RIGHT part on its own.

Why RIGHT and FIND only work for two words#

Many people first try RIGHT with FIND. FIND returns the position of a character in the text:

Excel formula
=RIGHT(A2,LEN(A2)-FIND(" ",A2))

For Tom Baker this works. LEN counts 9 characters, FIND finds the space at position 4, and RIGHT takes the last 9 - 4 = 5 characters: Baker.

For Maria Lopez Garcia it returns Lopez Garcia. FIND always finds the first space, so with three words you get the last two. This is the most common mistake with this task. You can fix it by finding the last space instead. This version counts the spaces, swaps the last one for a ^ sign, then finds the ^:

Excel formula
=RIGHT(A2,LEN(A2)-FIND("^",SUBSTITUTE(A2," ","^",LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))

For Maria Lopez Garcia, there are 2 spaces, so the second space becomes ^ at position 12, and RIGHT takes the last 18 - 12 = 6 characters: Garcia. It works, but the TRIM and REPT formula above is shorter and easier to check. See the FIND function guide for how FIND counts positions, and how FIND and SEARCH locate text for the difference between the two.

Handle cells with one word or extra spaces#

Real data is rarely clean. Three problems come up often.

No space in the cell. If a cell holds just "Cher", there is no space for TEXTAFTER to find, so it returns #N/A. Use the sixth argument, if_not_found, to return the whole cell instead:

Excel formula
=TEXTAFTER(A2," ",-1,,,A2)

The two empty arguments in the middle keep the default match mode and match end.

Trailing spaces. If a cell is "Tom Baker " with a space at the end, the last space comes after Baker, and TEXTAFTER returns an empty result. Clean the text first with TRIM, which removes spaces at the start and end and turns double spaces into single ones:

Excel formula
=TEXTAFTER(TRIM(A2)," ",-1)

Other separators. Product codes often use hyphens, like "LAP-15-SILVER". Change the delimiter: =TEXTAFTER(A2,"-",-1) returns SILVER. TEXTAFTER also accepts several delimiters at once in curly brackets, so =TEXTAFTER(A2,{" ","-"},-1) splits on whichever comes last.

Get everything except the last word#

Sometimes you need the opposite: the first name and middle name, without the last name. Use TEXTBEFORE with -1:

Excel formula
=TEXTBEFORE(A2," ",-1)

For Maria Lopez Garcia, the result is Maria Lopez. In older versions, use LEFT with the position of the last space from the formula above, minus 1.

The same idea works for other splits. To take the part after the @ sign in an email address, see how to extract the domain from an email. To take text from the middle of a cell, such as a code inside brackets, see extracting text between two characters.

When the last word is a number#

If the last word is a number, such as "Order total 450", the formulas above return text that looks like 450. SUM ignores it and comparisons may fail. Wrap the result in VALUE to turn it into a real number:

Excel formula
=VALUE(TEXTAFTER(A2," ",-1))

The result is the number 450, which you can add, average or compare. For numbers buried in the middle of text, the guide on extracting numbers from text covers more patterns.

Flash Fill: the no-formula option#

For a one-off list, Flash Fill can be quicker than any formula. Type Garcia in B2, move to B3, and choose Data > Flash Fill (on Windows the shortcut is Ctrl+E). Excel spots the pattern and fills the rest of the column.

Check the results before you trust them. Flash Fill guesses from your example, and an unusual row can break the pattern. It also writes plain values, so if a name in column A changes later, column B does not update. Use a formula when the list will change or when a test asks for one.

Practise it#

Splitting text is a common task in Excel job tests, and the -1 trick is easy to forget under time pressure. Practise TEXTBEFORE and TEXTAFTER in a live spreadsheet: you type the formula and it checks it instantly. Then try the FIND and SEARCH lesson to build the classic formulas that work in every version, or start with the exercise on this page.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Column A holds full names. In B2, use TEXTAFTER to return the last word of A2. Remember the -1 to start from the last space.

fx
ABCD
1
Full name
Last name
2
Maria Lopez Garcia
3
Tom Baker
4
Aisha Bello
5
Jean Paul Martin
6
Kenji Sato
7
Ana Sofia de Souza
8
9
10

Tip: TEXTAFTER needs the text, the delimiter (a space in quotes) and the instance number. -1 means the last space.

Practise this in a lesson

LessonTEXTBEFORE and TEXTAFTERSplit emails, "Last, First" names and file paths at a delimiter with TEXTBEFORE and TEXTAFTER, including picking which occurrence to split at.LessonFIND and SEARCHLocate a character or word inside text with FIND or SEARCH, then use that position to split names and pull out order numbers.Function guideRIGHTTake the last characters of a cell with Excel's RIGHT: account digits, file extensions and size codes. Examples, pitfalls and live practice.Function guideFINDLocate a character inside text with Excel's FIND, then use it with LEFT, MID and RIGHT. Case rules, #VALUE! fixes and a live exercise.

Frequently asked questions

How do I get the last word in a cell in Excel?

+

In Microsoft 365 or Excel 2024, use =TEXTAFTER(A2," ",-1). In older versions, use =TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100)). Both return the text after the last space.

How do I extract the last name from a full name in Excel?

+

If the last name is the last word, use the same formulas: =TEXTAFTER(A2," ",-1) in new Excel. This works for names with a middle name too, such as Maria Lopez Garcia, which returns Garcia.

Why does TEXTAFTER return #N/A?

+

The cell has no space, so there is no last space to start from. Add the sixth argument to return the whole cell instead: =TEXTAFTER(A2," ",-1,,,A2).

How do I remove the last word from a cell?

+

Use TEXTBEFORE with -1: =TEXTBEFORE(A2," ",-1) returns everything before the last space. For Maria Lopez Garcia it returns Maria Lopez.

Can Flash Fill extract the last word?

+

Yes. Type the last word of the first row in the next column, then use Data > Flash Fill. It is quick for a one-off list, but the results don't update when the names change.

Sources

  • TEXTAFTER function - Microsoft Support
  • RIGHT, RIGHTB functions - Microsoft Support
  • FIND, FINDB functions - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. The example data
  2. The quick way: TEXTAFTER with -1
  3. The classic way: RIGHT, SUBSTITUTE and TRIM
  4. Why RIGHT and FIND only work for two words
  5. Handle cells with one word or extra spaces
  6. Get everything except the last word
  7. When the last word is a number
  8. Flash Fill: the no-formula option
  9. Practise it

Keep reading

Text· 6 min read

Extract Text Between Two Characters in Excel

To extract text between two characters in Microsoft 365, nest TEXTAFTER inside TEXTBEFORE: =TEXTBEFORE(TEXTAFTER(A2,"("),")") returns what sits between the brackets. In any version, use MID and FIND: =MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1). FIND gives the positions of the two characters, and MID takes the text between them.

Text· 7 min read

Extract the Domain or Username From an Email in Excel

To extract the domain from an email address, take everything after the @ sign. In Microsoft 365, use =TEXTAFTER(A2,"@"). In any version, use =MID(A2,FIND("@",A2)+1,LEN(A2)). For the username, take everything before the @: =TEXTBEFORE(A2,"@") or =LEFT(A2,FIND("@",A2)-1). Wrap either in IFERROR for cells without an @.

Text· 6 min read

Extract Numbers From Text in Excel

To extract a number from text in Excel, cut it out with a text function and convert it with VALUE. For a number after a dash, use =VALUE(RIGHT(A2,LEN(A2)-FIND("-",A2))), or =VALUE(TEXTAFTER(A2,"-")) in Microsoft 365. Use LEFT for numbers at the start and MID for numbers in the middle. VALUE turns the result into a real number.

More on text

  • Find the Nth Occurrence of a Character in Excel
  • Find the Position of Text in a Cell (FIND and SEARCH)
  • How to Format Phone Numbers in Excel
  • Get Initials From a Name in Excel
  • How to Add or Keep Leading Zeros in Excel
  • LEFT, RIGHT and MID in Excel: Pull Out Part of a Cell
All text articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free