How to Extract the Last Word from a Cell in Excel
Get the last word of a product title — even with trailing spaces — and use it as a lookup key to price size variants.
You will learn to
- Extract the last word with TEXTAFTER
- Make it robust to trailing spaces
- Use the last word as a lookup key
How it works
In Excel 365 the last word is everything after the last space: =TEXTAFTER(A2," ",-1). Trailing spaces break this (the "last word" becomes empty), so TRIM the text first: =TEXTAFTER(TRIM(A2)," ",-1). For older versions the classic formula is =TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100)), which pads every space to 100 spaces and keeps the last 100 characters.
The last word is often meaningful data: a size at the end of a product title, a city at the end of an address line, a status at the end of a log entry. Once extracted, use it as a lookup key — for example to fetch a size surcharge with XLOOKUP.
=TEXTAFTER(TRIM(A2)," ",-1)