← All how-to recipes

How to extract the nth word from a cell

✓ Verified in LibreOffice 25.8.7.3

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

The formula

AppFormulaNotes
Excel=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. Every formula here is confirmed by actually executing it.