← All how-to recipes

How to extract the nth word from a cell

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Pull out the 1st, 2nd, or any specific word from a text cell.

The formula

AppFormulaNotes
Excel (desktop)=TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",100)),(2-1)*100+1,100))The 2 is the word number. Excel 365: =INDEX(TEXTSPLIT(A2," "),2) is far clearer.
Google Sheets=TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",100)),(2-1)*100+1,100))Or the Sheets-only =INDEX(SPLIT(A2," "),2).
LibreOffice Calc=TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",100)),(2-1)*100+1,100))Identical; INDEX(TEXTSPLIT(...)) works in 25.8+.

How it works

The classic trick: SUBSTITUTE pads every space to 100 spaces, so each word sits in its own 100-character "slot"; MID grabs slot n and TRIM strips the padding — word 2 of "alpha beta gamma" is "beta". It looks arcane but runs in every version of every app. On modern versions, INDEX(TEXTSPLIT(A2," "),2) says the same thing readably. The 100 just needs to exceed your longest word.

Verified, not just documented

We ran =TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",100)),(2-1)*100+1,100)) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned beta — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned beta for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.

Functions used

TRIM · MID · SUBSTITUTE · REPT — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related recipes

Related comparisons