Text formula page
Extract Last Word Formula
Use this for simple last names, final labels, or last tokens in imported text.
Extract the last word from a cell.
If A2 is Maya Chen, the result is Chen.
Copy formulas
=TEXTAFTER(TRIM(A2), " ", -1) =REGEXEXTRACT(TRIM(A2), "\S+$") Excel uses TEXTAFTER with an instance number. Google Sheets can use a regex for the last non-space run.
Example data
| Raw Text | Example Result |
|---|---|
| Maya Chen | Maya |
| SKU-1001-East | SKU |
| https://www.example.com/pricing | example.com |
| Acme North | Acme North |
Formula explanation
- TRIM normalizes extra spaces.
- Excel searches from the last space.
- Google Sheets captures the final non-space text.
What this formula does
Extract Last Word Formula is built around TEXTAFTER. The example formula on this page is =TEXTAFTER(TRIM(A2), " ", -1), and it is written against sample columns such as Raw Text, Example Result.
Excel and Google Sheets need different syntax for this task, so copy the version that matches the spreadsheet app you are using.
Text formulas are sensitive to spaces, delimiters, punctuation, and hidden line breaks. Clean the source text first when imported data contains inconsistent separators or nonbreaking spaces.
Use this pattern for this task: Extract the last word from a cell. Review a few edge cases before filling the formula down across a large import.
| Syntax piece | Role in the formula |
|---|---|
| TRIM | TRIM normalizes extra spaces. |
| Part 2 | Excel searches from the last space. |
| Part 3 | Google Sheets captures the final non-space text. |
Practical use cases
=TEXTAFTER(TRIM(A2), " ", -1) Excel: Use this on imported CRM, CSV, or content rows where one text cell needs to be cleaned or split before analysis. Returns: If A2 is Maya Chen, the result is Chen.
=REGEXEXTRACT(TRIM(A2), "\S+$") Google Sheets: Use this before lookup, filtering, or duplicate checks so the text key is consistent across rows. Returns: If A2 is Maya Chen, the result is Chen.
Common errors
- Hidden spaces and line breaks can make text formulas look wrong even when the syntax is valid.
- Modern Excel text functions such as TEXTSPLIT, TEXTBEFORE, and TEXTAFTER require newer Excel versions.
- Formula separators can vary by locale in some spreadsheet settings.
Common errors and troubleshooting
| Issue | Likely cause | Fix |
|---|---|---|
| Copied formula gives an unexpected result | Hidden spaces and line breaks can make text formulas look wrong even when the syntax is valid. | Normalize spacing first, confirm the delimiter or pattern exists, and wrap the formula in IFERROR only after the pattern is correct. |
| Common setup problem | Modern Excel text functions such as TEXTSPLIT, TEXTBEFORE, and TEXTAFTER require newer Excel versions. | Normalize spacing first, confirm the delimiter or pattern exists, and wrap the formula in IFERROR only after the pattern is correct. |
| Common setup problem | Formula separators can vary by locale in some spreadsheet settings. | Normalize spacing first, confirm the delimiter or pattern exists, and wrap the formula in IFERROR only after the pattern is correct. |
| Formula returns #VALUE! or no match | The delimiter, word boundary, or pattern expected by the formula is not present in that row. | Inspect a failed cell, confirm the delimiter exists, and add IFERROR only after the extraction rule is correct. |
| Output still contains strange spaces | The source text contains nonbreaking spaces, tabs, or line breaks that TRIM alone does not remove. | Use CLEAN or SUBSTITUTE for those characters before applying the final extraction or cleanup formula. |
When not to use this formula
- Do not use simple text formulas for complex CSV parsing with quoted commas.
- Do not use text extraction formulas when the source data should be cleaned once in a dedicated import step.
Alternatives
| Alternative | When to use it |
|---|---|
| CSV Column Cleaner | Use when header names need cleanup before import. |
| REGEXEXTRACT Formula Builder | Use for repeatable Google Sheets pattern extraction. |
| FILTER Formula Builder | Use after text cleanup when you need matching rows. |
Compare with related formulas
| Formula or tool | How it differs | Use it instead when |
|---|---|---|
| CSV Column Cleaner | CSV Column Cleaner solves a nearby workflow, while Extract Last Word Formula is focused on extract the last word from a cell. | Use when header names need cleanup before import. |
| REGEXEXTRACT Formula Builder | REGEXEXTRACT Formula Builder solves a nearby workflow, while Extract Last Word Formula is focused on extract the last word from a cell. | Use for repeatable Google Sheets pattern extraction. |
| FILTER Formula Builder | FILTER Formula Builder solves a nearby workflow, while Extract Last Word Formula is focused on extract the last word from a cell. | Use after text cleanup when you need matching rows. |
Test cases
| Test | Platform | Formula | Returns |
|---|---|---|---|
| Excel copy output | Excel | =TEXTAFTER(TRIM(A2), " ", -1) | If A2 is Maya Chen, the result is Chen. |
| Google Sheets copy output | Google Sheets | =REGEXEXTRACT(TRIM(A2), "\S+$") | If A2 is Maya Chen, the result is Chen. |
Related formulas
FAQ
What does the Extract Last Word Formula do?
It supports this task: Extract the last word from a cell. The example uses A2, but you should replace the ranges and criteria with the cells in your own workbook.
Does the Extract Last Word Formula work in Excel and Google Sheets?
Not exactly. This page shows a separate Google Sheets formula when the syntax differs.
What should I change before copying the formula?
Change the source ranges, criteria cells, and output range references so they match your sheet. Keep related ranges on the same rows unless the formula notes say otherwise.
Why does this text formula fail on some rows?
Those rows may not contain the delimiter, word boundary, or pattern the formula expects. Inspect failed examples before adding IFERROR.
Can I fill this formula down a whole import?
Yes, but first test rows with missing delimiters, extra spaces, blank cells, and unusual punctuation so the rule matches the real data.
Does this formula clean hidden spaces?
Some formulas use TRIM, but nonbreaking spaces and line breaks may need CLEAN or SUBSTITUTE before the final extraction step.