Extract nth word from text string

An excel formula to extract nth word from text string

Related Functions

Sponsored Link

 Extract nth word from text string
=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))), (N-1)*LEN(A1)+1, LEN(A1)))

If you need to get the nth word in a text string (i.e. a sentence, phrase, or paragraph) you can so with a clever (and intimidating) formula that combines 5 Excel functions: TRIM, MID, SUBSTITUTE, REPT, and LEN.

How this formula works

At the core, this formula takes a text string with spaces, and "floods" it with additional spaces by replacing each space with a number of spaces using SUBSTITUTE and REPT. The number of spaces used is based on the overall length of the original text.

You can think of the result at this point as "islands" of words floating in a sea of space:)

Then the formula uses the MID function to extract the desired word. The starting point is worked out with:

(N-1)*LEN(A1)+1

And the total characters extracted is equal to the length of the full text string.

At this point, we have the word you want, surrounded by spaces. Finally, the TRIM function slices off all space characters and returns just the word.

I really like this formula, because it shows off what you can accomplish with some creative thinking.

Text to Columns

Don't forget that Excel has a built-in Text to Columns feature that can split text according to the delimiter of your choice. If you just need to get the 3rd word from a lot of text strings, the formula may be more convenient (and dynamic), but Text to Columns is still useful in many situations.

Sponsored Link

0 votes. 0 / 5