To extract the last word in any version of Excel, use =TRIM(RIGHT(SUBSTITUTE(TRIM(A2)," ",REPT(" ",LEN(A2))),LEN(A2))). On "Merino Trail Sock Charcoal" it returns "Charcoal". In Microsoft 365 and Excel 2024, =TEXTAFTER(TRIM(A2)," ",-1) does the same in one function. Both ignore how many words the cell holds.
Functions
Extract the Last Word in Excel: Formulas That Work
Ready to practice?
Apply what you just learned with interactive exercises.
The long formula looks odd, so this page takes it apart, then covers TEXTAFTER, TEXTSPLIT with TAKE, Flash Fill, and the stray-space traps that quietly return a blank.
TL;DR
- Every version: =TRIM(RIGHT(SUBSTITUTE(TRIM(A2)," ",REPT(" ",LEN(A2))),LEN(A2))). It stretches every space into a wide gap, takes the right-hand slice, and trims the padding.
- Microsoft 365 and Excel 2024: =TEXTAFTER(TRIM(A2)," ",-1). The -1 means "count the delimiter from the end".
- Also in newer Excel: =TAKE(TEXTSPLIT(TRIM(A2)," "),,-1) splits into words and keeps the last one.
- If a cell has exactly two words, =RIGHT(A2,LEN(A2)-FIND(" ",A2)) is enough.
- A trailing space makes the long formula return an empty string. The inner TRIM prevents it.
- A single-word cell returns itself with the long formula, and #N/A with TEXTAFTER unless you handle it.
Table of Contents
- Sample data used on this page
- The shortcut for cells with exactly two words
- The REPT, SUBSTITUTE and RIGHT formula explained
- Why a trailing space returns a blank
- Find the last space instead
- TEXTAFTER with a negative instance
- TEXTSPLIT with TAKE
- Flash Fill for the last word
- Everything except the last word
- The last two words
- Count rows by their last word
- Which method to choose
- Excel versions
- Errors and their fixes
- What learners get wrong
- Worked scenario: split colour from product name
- Practice the building blocks
- FAQ
- Sources
Sample data used on this page
An outdoor-gear shop exports its catalog with the colour as the last word of each product name. The names have different numbers of words and a few have messy spacing. Row 1 holds the header.
| Row | A (Product) | What is special about it |
| 2 | Merino Trail Sock Charcoal | Four words |
| 3 | Insulated Water Bottle Blue | Four words |
| 4 | Rain Jacket Forest Green | The colour is two words |
| 5 | Headlamp Black | Two words |
| 6 | Poncho | One word, no space |
| 7 | Camp Towel Sand | Leading space, two spaces in the middle, trailing space |
| 8 | Hiking Pole Carbon-Black | The last word contains a hyphen |
The shortcut for cells with exactly two words
When every cell holds two words, you do not need anything clever. The last word is whatever follows the single space:
=RIGHT(A5,LEN(A5)-FIND(" ",A5))
On A5 it returns "Black". LEN gives the total length, FIND gives the position of the space, and the difference is the number of characters after the space. The same pattern on a different sheet, with "Mike Johnson" in A2, returns "Johnson" from =RIGHT(A2,LEN(A2)-FIND(" ",A2)). =RIGHT(A2,7) gives the same answer only if you already know the word has 7 letters.
Try it on A2 and you see why it fails for longer text: =RIGHT(A2,LEN(A2)-FIND(" ",A2)) returns "Trail Sock Charcoal", because FIND stops at the first space, not the last. For anything beyond two words, you need a method that finds the last space.
The REPT, SUBSTITUTE and RIGHT formula explained
This works in every version, so it is worth understanding rather than pasting.
=TRIM(RIGHT(SUBSTITUTE(TRIM(A5)," ",REPT(" ",LEN(A5))),LEN(A5)))
Take A5, "Headlamp Black", which is 14 characters long, and work from the inside out.
- TRIM(A5) removes any stray spaces. Here it changes nothing.
- REPT(" ",LEN(A5)) makes a string of 14 spaces. The width is the length of the whole cell, which is always at least as long as the longest possible last word.
- SUBSTITUTE(...," ",...) replaces every space in the text with those 14 spaces. "Headlamp Black" becomes "Headlamp", then 14 spaces, then "Black". That string is 27 characters long.
- RIGHT(...,LEN(A5)) keeps the last 14 characters. Because the last word is shorter than 14, those 14 characters hold the word "Black" plus 9 spaces of padding in front of it.
- TRIM(...) strips the padding and leaves "Black".
A single-word cell survives it too. On A6 there is nothing to substitute, RIGHT keeps all of "Poncho", and the result is "Poncho". The width is the reason to use LEN of the cell and not a fixed number like 100. A fixed 100 works on short text but cuts a long last word, and a 100-character word is unlikely, not impossible. Using LEN removes the guesswork.
Why a trailing space returns a blank
Now try the version without the inner TRIM on A7, which has spaces at both ends:
=TRIM(RIGHT(SUBSTITUTE(A7," ",REPT(" ",LEN(A7))),LEN(A7)))
It returns an empty string. The text ends with a space, and that space is swapped for 18 spaces. The final 18 characters are then all padding, so RIGHT sees no word at all, and TRIM leaves nothing.
The version with TRIM around the cell, =TRIM(RIGHT(SUBSTITUTE(TRIM(A7)," ",REPT(" ",LEN(A7))),LEN(A7))), returns "Sand". The inner TRIM removes the end spaces and the double space in the middle before the substitution. Make the inner TRIM a habit. The cost is nothing and the failure it prevents is silent. For more on what TRIM does and does not remove, see the TRIM guide, and for the replacement step see the SUBSTITUTE guide.
One more source of blanks: a non-breaking space (character 160), common in text pasted from web pages, is not a normal space and TRIM leaves it alone. If the formula returns the whole cell instead of the last word, replace code 160 with a normal space using SUBSTITUTE and UNICHAR(160) before anything else.
Find the last space instead
The second classic approach finds the position of the last space directly. It swaps only the last space for a marker character, then finds the marker.
=RIGHT(A2,LEN(A2)-FIND("~",SUBSTITUTE(A2," ","~",LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))
Four steps again. LEN(A2)-LEN(SUBSTITUTE(A2," ","")) counts the spaces, which is 3 in A2. SUBSTITUTE's optional fourth argument replaces only the third space with a tilde. FIND locates that tilde, at position 18. RIGHT keeps the characters after it: "Charcoal".
Choose a marker that does not appear in your text. A tilde is rarely used, but check. This version fails on a single-word cell: with zero spaces the instance number is 0, and SUBSTITUTE returns #VALUE!. On A6 the formula returns an error, where the REPT formula returned the word. That is why the REPT version is usually the better default.
TEXTAFTER with a negative instance
In Microsoft 365 and Excel 2024, TEXTAFTER returns the text after a delimiter, and a negative instance number starts counting from the end. So -1 means the last delimiter.
=TEXTAFTER(TRIM(A2)," ",-1)
This returns "Charcoal". It does the job of the long formula in a short one, with no padding trick. Microsoft's page for the sibling function TEXTBEFORE says a negative instance number starts searching from the end of the text, and TEXTAFTER takes the same argument.
Keep TRIM in the formula. TEXTAFTER takes the text after the last delimiter literally, so a trailing space would give you an empty string.
A cell with no space returns #N/A. Handle it with IFERROR: =IFERROR(TEXTAFTER(TRIM(A6)," ",-1),TRIM(A6)) returns "Poncho".
TEXTBEFORE with -1 gives the opposite half: =TEXTBEFORE(TRIM(A2)," ",-1) returns "Merino Trail Sock", the text before the last space.
TEXTSPLIT with TAKE
Another route splits the cell into words, then keeps the last one. TEXTSPLIT puts each word in its own cell, and TAKE picks from the result.
=TAKE(TEXTSPLIT(TRIM(A2)," "),,-1)
TEXTSPLIT returns four words in a row. TAKE with no row count and a column count of -1 keeps the last column, so you get "Charcoal". This approach shines when you also want other positions: TAKE(...,,1) is the first word, and TAKE(...,,-2) is the last two as separate cells.
TEXTSPLIT and TAKE are in Microsoft 365 and Excel 2024. A formula that returns one value from them spills a single cell, so it behaves like any other formula.
Flash Fill for the last word
For a one-off, Flash Fill needs no formula.
- In B2 type the last word of A2: Charcoal.
- In B3 start typing the last word of A3.
- When Excel shows the gray preview, press Enter. On Windows, Ctrl+E does the same.
Everything except the last word
With the last word in a helper column, removing it is arithmetic. If B2 holds "Charcoal", then =LEFT(A2,LEN(A2)-LEN(B2)-1) returns "Merino Trail Sock". The extra minus 1 removes the space before the word. In 365, =TEXTBEFORE(TRIM(A2)," ",-1) skips the helper altogether.
The last two words
Widen the slice in the REPT formula. Doubling the width in RIGHT keeps two words:
=TRIM(RIGHT(SUBSTITUTE(TRIM(A4)," ",REPT(" ",LEN(A4))),2*LEN(A4)))
On A4 it returns "Forest Green". RIGHT now keeps 2 times the length, which reaches back through the padding to the word before the last, but not far enough to touch the third word from the end. Use 3 times the length for three words.
Count rows by their last word
COUNTIF with a wildcard counts rows ending in a word, but watch the edges. =COUNTIF(A2:A8,"*Black") returns 2, because "Carbon-Black" in row 8 also ends in those five letters. Add the space to the pattern, =COUNTIF(A2:A8,"* Black"), and the answer is 1. The COUNTIF guide explains the wildcards. Rows with trailing spaces will not match a pattern that expects the word at the very end, so clean first.
Which method to choose
| Method | Works in | Handles one word | Handles extra spaces | Notes |
| =RIGHT(A5,LEN(A5)-FIND(" ",A5)) | Every version | No | No | Two-word cells only |
| REPT, SUBSTITUTE, RIGHT, TRIM | Every version | Yes | Yes, with inner TRIM | Best default for shared workbooks |
| Marker and FIND | Every version | No, returns an error | Needs TRIM | Good when you also need the position |
| =TEXTAFTER(TRIM(A2)," ",-1) | Microsoft 365, Excel 2024 | Needs IFERROR | Needs TRIM | Shortest and clearest |
| =TAKE(TEXTSPLIT(TRIM(A2)," "),,-1) | Microsoft 365, Excel 2024 | Yes | Needs TRIM | Useful when other positions matter |
| Flash Fill | Excel 2013 and later | Usually | Check | Static |
Excel versions
RIGHT, LEN, FIND, SUBSTITUTE, REPT and TRIM are in every desktop version of Excel. TEXTBEFORE, TEXTSPLIT and TAKE are listed by Microsoft for Microsoft 365 and Excel 2024 on Windows and Mac, and TEXTAFTER is its twin from the same release. None of them are in Excel 2021 or 2019. The Microsoft pages do not list Excel for the web, so test there by typing the name and watching for autocomplete.
Errors and their fixes
| What you see | Cause | Fix |
| An empty string | A trailing space turned the final slice into padding | Put TRIM around the cell inside SUBSTITUTE |
| #VALUE! from the marker formula | The cell has no space, so the instance number is 0 | Use the REPT formula, or wrap in IFERROR |
| #N/A from TEXTAFTER | There is no space to find | Wrap in IFERROR with the trimmed cell as the fallback |
| #NAME? | The version does not have TEXTAFTER, TEXTSPLIT or TAKE | Use the REPT formula |
| The whole text comes back | A non-breaking space, code 160, was not treated as a space | SUBSTITUTE it to a normal space first |
| "Green" instead of "Forest Green" | The rule is the last word, and the colour has two | Use the last-two-words version, or a lookup list |
| Last word cut short | A fixed width such as 100 was smaller than the word | Use LEN of the cell as the width |
What learners get wrong
Between 26 September and 3 November 2026, our LEN, LEFT, and RIGHT Functions lesson logged 832 first attempts on the screen that asks for =RIGHT( ) to return "Johnson", and 50.0% were right. A first attempt is the first check of a screen in a page view, not a person. The accepted answer is =right(a2,7).
That screen is the last-word problem in miniature. RIGHT needs two things, the cell and a count, and the common wrong answers each leave one out or get the count wrong:
- No count. 175 first attempts typed =right(a2). With the count omitted RIGHT returns a single character, so the result is "n" and not the surname.
- No arguments at all. 156 typed =right(). The formula has nothing to work on.
- A guessed count. 43 typed =right(a2,4) and 27 typed =right(a2,5). Both are valid formulas with the wrong number. The count must equal the length of the word you want, here 7.
- No cell. 42 typed =right(7), supplying only the count. RIGHT then takes the number 7 as the text, and the result is "7".
- The word typed in. 19 typed =right("Johnson"), the quoted word with no count, which again returns a single character.
Worked scenario: split colour from product name
Your merchandiser wants the colour in its own column so the shop can filter by it, with the rest of the name left as the product.
- In B2 add the last word, safely: =TRIM(RIGHT(SUBSTITUTE(TRIM(A2)," ",REPT(" ",LEN(A2))),LEN(A2))). Fill down. The results are Charcoal, Blue, Green, Black, Poncho, Sand and Carbon-Black.
- Spot the oddities. Row 4 says "Green" but the colour is "Forest Green". Row 6 has no colour at all, because "Poncho" is the product. Row 8 has a hyphenated colour that is correct.
- Fix row 4 by hand, or switch it to the last-two-words formula =TRIM(RIGHT(SUBSTITUTE(TRIM(A4)," ",REPT(" ",LEN(A4))),2*LEN(A4))), which returns "Forest Green".
- Remove the colour from the name in C2 with =LEFT(A2,LEN(A2)-LEN(B2)-1) on a clean row such as row 2, which returns "Merino Trail Sock". Check rows with leading or trailing spaces, because LEN counts those too.
- Count the black items with =COUNTIF(A2:A8,"* Black"), which returns 1.
- Paste the finished columns as values before importing.
Practice the building blocks
The last-word formulas are RIGHT, LEN, FIND and SUBSTITUTE in combination. Open Lesson 13, LEN, LEFT, and RIGHT Functions and type the formula there, then read the guide to the first word to see the mirror-image problem. For the family of text functions, the text functions guide is the best map.
FAQ
How do I get the last word in a cell in Excel?
In any version, use =TRIM(RIGHT(SUBSTITUTE(TRIM(A2)," ",REPT(" ",LEN(A2))),LEN(A2))). In Microsoft 365 or Excel 2024, =TEXTAFTER(TRIM(A2)," ",-1) is shorter. Both return the text after the final space, however many words the cell holds.
Why does my last word formula return a blank?
The cell almost certainly ends with a space. The formula pads every space, so a trailing one becomes pure padding and the last slice contains no word. Put TRIM around the cell inside SUBSTITUTE, and the end spaces disappear before the padding is added.
What does the -1 in TEXTAFTER mean?
The third argument of TEXTAFTER is instance_num, which picks which occurrence of the delimiter to use. A positive number counts from the start of the text, and a negative number counts from the end. So -1 is the last occurrence, which is why it returns the last word.
Can I get the last word without a formula?
Yes. Use Flash Fill: type the last word beside the first row, start the second, and press Enter when the preview appears, or press Ctrl+E on Windows. The result is static, so it will not update if the source changes, and you should scan it for wrong guesses.
How do I get the last word from a cell with only one word?
The REPT formula returns the word itself. TEXTAFTER returns #N/A because there is no space, so wrap it: =IFERROR(TEXTAFTER(TRIM(A6)," ",-1),TRIM(A6)). The marker formula using FIND returns #VALUE! on a single word, so avoid it if such cells are possible.
How do I get the last two words of a cell?
Double the slice width in the REPT formula: =TRIM(RIGHT(SUBSTITUTE(TRIM(A4)," ",REPT(" ",LEN(A4))),2*LEN(A4))) returns "Forest Green" from "Rain Jacket Forest Green". Use 3 times the length for three words. In newer Excel, TAKE with -2 gives them as separate cells.
Sources
Keep going
Guides people read next.
Extract First Word in Excel: Formulas and Shortcuts
Extract the first word from a cell in Excel with LEFT and FIND, handle one-word cells and stray spaces, or use TEXTBEFORE and Flash Fill.
14 min
XLOOKUP With Multiple Criteria: 3 Formulas That Work
Use XLOOKUP with two or more conditions in Excel: Boolean, concatenation and OR formulas, last-match tricks, FILTER for all matches, and fixes for errors.
13 min
Dynamic Arrays in Excel: Spill Formulas Explained
Learn how dynamic arrays in Excel work: spilling, FILTER, SORT, UNIQUE, the @ operator, #SPILL! fixes and version support, with examples you can type.
15 min