30 Advanced Excel Tips for 2026

Excel Champs / Excel Formulas List / How to Extract Last Word from a Cell in Excel (Formula)
By Puneet Gogia (Microsoft MVP)

How to Extract Last Word from a Cell in Excel (Formula)

30+ Advanced Excel Tips for 2026

No spam. Only Excel Stuff. God Promise. 😊

To pull the last word out of a cell, use =TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1))). It works by replacing every space with a huge block of spaces — as many as there are characters in the whole string — so the last word ends up sitting alone at the far right. RIGHT then grabs a chunk that’s guaranteed to contain it, and TRIM strips the padding away.

In Excel 365 and 2021 there’s a one-argument version: =TEXTAFTER(A1," ",-1), where the -1 means “search from the end”. Two things to watch. A cell holding a single word returns that word with both formulas, which is usually what you want, but a trailing space breaks the padding version — wrap the reference in TRIM first: =TRIM(RIGHT(SUBSTITUTE(TRIM(A1)," ",REPT(" ",LEN(A1))),LEN(A1))). And to get the first word instead, swap RIGHT for LEFT, or use =TEXTBEFORE(A1," ") in 365.

To get the last word from a cell, you must combine the TRIM, RIGHT, LEN, REPT, and SUBSTITUTE functions in Excel.

These functions help you locate the last space in the cell, and then, based on that space, you can extract the last word. Excel doesn’t have an exact formula to complete it, so you need to create a custom formula.

extract-last-word-from-a-cell

Excel Formula to Get the Last Word from a Cell

Here’s the formula that you need to use:

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)))

To understand how this formula works, we need to break it into parts.

In this first part, we have REPT and LEN functions. The LEN function returns the count of characters in the original value, and the REPT function returns spaces according to that number (character count).

rept-and-len-functions

If there are 59 characters in the original value, REPT will return 59 spaces. See the below screenshot.

rept-returns-values

Next, in the second part, we have the SUBSTITUTE function, which replaces each space in the cell with the spaces returned by the REPT function.

substitue-replace-each-space

If there are 10 spaces in the cell, SUBSTITUTE replaces each of those 10 spaces with 59 spaces. 59 spaces between each word instead of 1. See the screenshot below.

value-returned-by-substitute

After that, in the third part, we have the RIGHT function that extracts characters (equal to the character count of the original value) from the value we have got above.

right-function-extracts-characters

And below is the value it returns.

trim-value-in-return

As there are 59 characters in the original value, it extracts 59 characters from the new values. In this extracted value, we have 5 characters of the last word (guide), and the rest are spaces.

Now in the fourth part, we have the TRIM function that removes the extra spaces from the value and returns only the last word (guide).

The formula works for a cell with a single word as well; it returns that word.

When the Cell Has a Space at the End

There’s one catch with this formula. If the text has a space at the end (which is common with imported data), the formula returns a blank, because the last “word” is the empty text after that space. To fix this, use TRIM on the cell inside SUBSTITUTE:

=TRIM(RIGHT(SUBSTITUTE(TRIM(A1)," ",REPT(" ",LEN(A1))),LEN(A1)))

This version removes the extra spaces first and then gets the last word, so it’s safe to use for all your data.

Get the Last Word with TEXTAFTER

If you use Excel for Microsoft 365 or Excel 2024, TEXTAFTER does the same job with a much shorter formula. The -1 tells it to use the last space instead of the first one:

=TEXTAFTER(TRIM(A1)," ",-1)

With a single word in the cell, TEXTAFTER returns the #N/A error because there’s no space to look for. Use the last argument, if_not_found, to return the whole text in that case:

=TEXTAFTER(TRIM(A1)," ",-1,,,TRIM(A1))

Now, a cell with one word returns that word instead of an error.

Get the Last Word after a Comma or Another Character

The same formula works with any other separator. Just replace the space in the SUBSTITUTE part with that character. For example, for “Smith, John”, the following formula returns “John”:

=TRIM(RIGHT(SUBSTITUTE(A1,",",REPT(" ",LEN(A1))),LEN(A1)))

Remove the Last Word from a Cell

And if you need everything except the last word, take the length of the last word away from the length of the text and use LEFT:

=TRIM(LEFT(TRIM(A1),LEN(TRIM(A1))-LEN(TRIM(RIGHT(SUBSTITUTE(TRIM(A1)," ",REPT(" ",LEN(A1))),LEN(A1))))))

For “This is the complete guide”, it returns “This is the complete”.

Frequently Asked Questions

Why does the formula return a blank cell?

The text ends with a space (or another invisible character). Use the TRIM(A1) version shown above. If it still returns a blank, the text may end with a non-breaking space from a web page; replace it first with SUBSTITUTE(A1,CHAR(160),” “).

Can I extract the last word without a formula?

Yes. Type the last word of the first cell in the next column, select the cell below, and press Ctrl + E (Flash Fill). Excel fills the rest by following your example, but the result doesn’t update when the text changes.

How do I get the last two words?

With TEXTAFTER, use -2 to start from the second-last space: =TEXTAFTER(TRIM(A1),” “,-2). In older versions, this is easier with Flash Fill.

trim replaces extra spaces
Puneet Gogia

Written by

Puneet Gogia

Microsoft MVP — Excel · Founder, Excel Champs

Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.

3M+ readers helped
1,000+ tutorials written
Since 2015 teaching Excel

Leave a Comment