The result in column D is the nth word of the text in column B, where n is given in column C. Note: The TEXTSPLIT function is new in Excel. See below for a formula that works in Legacy Excel.

### TEXTSPLIT function

The TEXTSPLIT function provides a simple way to solve this problem. As the name implies, TEXTSPLIT will split text into pieces using a custom delimiter. In the example shown, the formula in cell D5 is: Working from the inside out, the TEXTSPLIT function is configured to split text at each space (" “) character: Text comes from cell B5. The col_delimiter argument is provided as a single space (” “). The result from TEXTSPLIT is an array that includes each word in the text: To retrieve the word at the nth position in this array, we use the INDEX function. The array is returned directly to the INDEX function as the array argument. The row_num argument is provided as a reference to cell C5. With the number 3 in cell C5, INDEX returns the 3rd word in the array: The result from INDEX is the word “devil”. As the formula is copied down, it returns the nth word from each text string in column B, where n is provided in column C. If n is changed to a different number in any row, INDEX will retrieve a new word. Note that if n is greater than the number of words in a given text string, INDEX will return a #REF error.

### Removing extra space

The operation of this formula depends on there being a single space between each word. If there is the possibility of more than one space between words, the formula may return incorrect results. To handle this situation, you can use the TRIM function like this: The TRIM function will remove any leading or trailing spaces from the text string in column B, and will normalize space between words as well. The resulting text is then passed into the TEXTSPLIT function as before. This ensures that the results from TEXTSPLIT will be consistent.

### Legacy Excel

If you are working in an older version of Excel without the TEXTSPLIT function, you can use a more complicated formula to extract the nth word. In the screen below the formula in D5 combines five Excel functions: TRIM, MID, SUBSTITUTE, REPT, and LEN: The result in column D is the nth word of the text in column B, where n is given in column C:

At the core, this formula takes a text string and “floods” it with a large number of space characters between words using SUBSTITUTE and REPT. Then it splits the text string between words and cleans up the result with the TRIM function. Working from the inside out, the SUBSTITUTE function is used to replace all single spaces with many spaces: The REPT function and LEN function are used to calculate the number of spaces to use: LEN returns 25, so the REPT function returns a string of 25 spaces: Note: the number of spaces needs to be large enough to work in all cases. Using the LEN function to calculate the length of the original text string, and using this as the number of spaces, ensures that the formula will work even for very long words in the original text. The result from REPT is returned directly to the SUBSTITUTE function: SUBSTITUTE then replaces every single space in the text from B5 with 25 spaces. You can think of the result at this point as “islands” of words floating in a sea of space :) The result from SUBSTITUTE is returned directly to the MID function. The formula uses the MID function to extract the nth word. The start_num is worked out with this snippet: This code is designed to calculate the correct starting point to extract text, taking into account the fact that we’ve already flooded the text with extra space characters. We are just repeating the logic used previously to calculate the number of spaces to use between words. The n-1 adjustment is needed because the extra space occurs between words, i.e. the 3rd word occurs after the 2nd block of space, the 4th word occur after the 3rd block of space, etc. The length of the original text string is 25 characters and n is 3, so we have: The num_chars argument is provided as the original length of B5, which is 25. With this information, the MID function extracts 25 characters, beginning with character 51. The result is returned directly to the TRIM function: TRIM strips the space and returns the final result: “devil”.

### Alternate formula

It is also possible to extract the nth word from a text string in Legacy Excel with this formula, based on the FILTERXML function.

### Text to Columns

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

### Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.