Extract the Last Word

Excel Formulas › Text

All versionsTRIM

Pull the last word — a surname, a file extension, a unit. The classic trick pads the last space out wide so RIGHT can grab the final chunk, no matter how many words.


Quick formula: last word of A2:
=TRIM(RIGHT(SUBSTITUTE(A2, " ", REPT(" ", 100)), 100))
Replace each space with 100 spaces, take the rightmost 100 characters, then TRIM — what’s left is the last word.

Functions used (tap for the full reference guide):

The example

The last word isolated from a phrase.

AB
1TextLast word
2Ann Marie LeeLee

The formula

Pad spaces, grab the right end:

=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)), 100)) // isolates the final word

How it works

The space-padding trick:

  1. SUBSTITUTE(A2, " ", REPT(" ", 100)) replaces every space with 100 spaces, spreading the words far apart.
  2. RIGHT(…, 100) grabs the last 100 characters — guaranteed to contain just the final word (plus padding).
  3. TRIM removes the extra spaces, leaving the last word.
  4. In Excel 365, TEXTAFTER(A2, " ", -1) does it directly — the -1 means “after the last space.”

Why 100? It just needs to exceed the longest word. Bump it higher for very long words. The 365 TEXTAFTER(A2, " ", -1) avoids the whole trick — use it where available.

Try it: interactive demo

Live demo

Type text; get the last word.

Last word:

Variations

365 version

Direct:

=TEXTAFTER(A2, " ", -1)

File extension

After the last dot:

=TRIM(RIGHT(SUBSTITUTE(A2,".",REPT(" ",100)),100))

Everything but last word

The rest:

=LEFT(A2, LEN(A2)-LEN(lastWord)-1)

Pitfalls & errors

Padding width. 100 must exceed the longest word; increase it for unusually long tokens.

Trailing spaces. A space at the end can make the “last word” blank — TRIM the input first.

Single word. With no space, the trick returns the whole (trimmed) word — which is correct.

Practice workbook

📊
Download the free Extract the Last Word practice workbook
A last-word extractor with the 365, extension, and rest variants, plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I extract the last word in Excel?
Use =TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100)). It pads spaces so RIGHT can grab the final word. In 365, use =TEXTAFTER(A2, " ", -1).
Why does the formula use REPT(" ",100)?
It spreads the words far apart so the rightmost 100 characters contain only the last word. The number just needs to exceed the longest word.
What's the simplest modern version?
=TEXTAFTER(A2, " ", -1) returns the text after the last space — the last word — in Excel 365.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: Extract first word · Extract Nth word · TEXTBEFORE & TEXTAFTER

Function references: TRIM · SUBSTITUTE