# How to remove the last word from a cell in Excel

Keep the text before the last space: =TEXTBEFORE(A2," ",-1) in Excel 365.

**Excel:** `=TEXTBEFORE(A2," ",-1)` (Microsoft 365 only)

**Google Sheets:** `=REGEXREPLACE(A2,"\s+\S+$","")`

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Product title | Without size |
| Cotton T-shirt Large |  |
| Wool socks Medium |  |
| Rain jacket XL |  |
| Running shorts Small |  |
| Beanie OneSize |  |

Formula in B2, filled to B6: `=TEXTBEFORE(A2," ",-1)`

Result: Cotton T-shirt; Wool socks; Rain jacket; Running shorts; Beanie

## How it works

Instance `-1` makes TEXTBEFORE split at the last space, so everything before it is kept however many words the title has.

In Google Sheets, the pattern matches the last space and the word after it at the end of the text, and REGEXREPLACE deletes them.

## Other ways

- `=LEFT(A2,FIND(CHAR(1),SUBSTITUTE(A2," ",CHAR(1),LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))-1)`: Works in every version: find the position of the last space and keep everything before it.

## Common mistakes

- A trailing space makes the last "word" empty, so nothing useful is removed. Use `TEXTBEFORE(TRIM(A2)," ",-1)`.
- A one-word cell returns #N/A. Keep it unchanged with `=TEXTBEFORE(A2," ",-1,,,A2)`.

## Questions

**How do I remove the first word instead?**

Keep the text after the first space: `=TEXTAFTER(A2," ")`.

**How do I get the last word itself?**

Use `=TEXTAFTER(A2," ",-1)`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/remove-the-last-word
