Skip to main content

Text formula page

Extract Last Word Formula

Use this for simple last names, final labels, or last tokens in imported text.

Best for

Extract the last word from a cell.

What it returns

If A2 is Maya Chen, the result is Chen.

Copy formulas

Excel formula
=TEXTAFTER(TRIM(A2), " ", -1)
Google Sheets formula
=REGEXEXTRACT(TRIM(A2), "\S+$")
Excel / Google Sheets difference

Excel uses TEXTAFTER with -1 to search from the last delimiter. Google Sheets uses REGEXEXTRACT for the final non-space run.

Example data

Raw TextExample Result
Maya ChenMaya
SKU-1001-EastSKU
https://www.example.com/pricingexample.com
Acme North Acme North
What it returns

If A2 is Maya Chen, the result is Chen.

How the formula works

  • TRIM normalizes extra spaces.
  • Excel searches from the last space.
  • Google Sheets captures the final non-space text.
Syntax pieceRole in the formula
TRIM(A2)The source text with regular leading and trailing spaces removed.
" "The whitespace delimiter used by Excel.
-1The Excel instance number that selects the last delimiter.
\S+$The Google Sheets regex for the final non-space run.

Verified examples

Last name from full name
=TEXTAFTER(TRIM(A2), " ", -1)

Excel: Enter Maya Chen in A2. Returns: Chen

Padded final token
=REGEXEXTRACT(TRIM(A2), "\S+$")

Google Sheets: Enter two leading spaces, Acme, three spaces, North, and two trailing spaces in A2. Returns: North

Single token
=REGEXEXTRACT(TRIM(A2), "\S+$")

Google Sheets: Enter SKU-1001-East in A2. Returns: SKU-1001-East

Common errors and fixes

IssueLikely causeFix
The last word is not foundThe text contains nonbreaking spaces that TRIM does not normalize.Replace imported nonbreaking spaces before extracting the final token.
Trailing punctuation remainsThe extraction identifies the final token but does not remove punctuation.Apply punctuation cleanup separately when the output needs plain letters or digits.
TEXTAFTER is unavailableThe Excel version does not include the modern TEXTAFTER function.Use a legacy RIGHT, LEN, and FIND pattern or the split-text alternative.

When not to use this formula

  • Do not use this pattern when a URL host, file extension, or punctuation-delimited field needs URL-aware parsing.

Alternatives

AlternativeWhen to use it
Split Text FormulaUse when the complete set of tokens should be split into separate cells.
Extract First Word FormulaUse when the first token is the required output.

Related formulas

Official references

FAQ

What does -1 mean in TEXTAFTER?

It tells TEXTAFTER to use the last occurrence of the delimiter rather than the first.

Does the formula remove final punctuation?

No. Punctuation attached to the final token remains in the result.