VBA – Find the nth Word in a String of Text

Associated Files Download Links

Return nth Word in String of Text

The following function will find the nth word in a string:

It needs two arguments – the phrase that is to be searched and the word number:

Find_nth_word(“Automateexcel ls the worlds favourite Excel site”,4)

Will return “world”.

A blank is returned if the number of words in the phrase is less than the word number specified.

So: Find_nth_word(“Automateexcel ls the worlds favourite Excel site”,12)
Will return blank as there are not 12 words in the phrase “Automateexcel ls the worlds favourite Excel site”.


To download the .XLSM file from this article, click here

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text

Learn More!

<<Return to VBA Examples

Did you find this VBA tutorial useful? Then share it with your friends and colleagues:

You may also like some of this related content...

VBA has many string functions that will allow you to manipulate and work with text
In VBA, you can compare two strings using the StrComp function. In this tutorial, you
Reverse a String of Text with VBA The VBA Routine below allows the user to
INSTR Function You can use the Instr Function in VBA to test if a string
If you always know the length of a string, it's easy to remove characters from