Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to extract first / last / nth word from text string in Excel?

Have you ever suffered with the problem that you need to extract a certain word from the text string in a worksheet? For example, you have the following range of text strings needed to get the first/last or nth word from them, here I can talk about some effective ways for you to solve it.

Extract first word or last name from text string with formulas

Extract nth word from text string with User Defined Function

Extract each word from text string and list them horizontally or vertically

Easily mass extract the first names and last names from full names in Excel

Kutools for Excel's Split Names utility can help you quickly mass split full names to first names, middle names, and last names with several clicks in Excel. Full Feature Free Trial 60-day!
ad split names 2


arrow blue right bubble Extract first word or last name from text string with Formulas

Looking to extract the first word from a list of text strings, the following formulas can help you.

To extract the first word, please enter this formula =IF(ISERR(FIND(" ",A2)),"",LEFT(A2,FIND(" ",A2)-1)) into a blank cell, and then drag this cell's AutoFill handle to the range as you need.

And now you will see the first word is extracted from each cell. See screenshot below:

Notes:

(1) In above formula, A2 indicates the cell you want to apply this formula.

(2) For extracting the last words from each cell, please apply this formula: =IF(ISERR(FIND(" ",A2)),"",RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2," ","*",LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))).

note ribbon Formula is too complicated to remember? Save the formula as an Auto Text entry for reusing with only one click in future!
Read more…     Free trial

arrow blue right bubble Extract nth word from text string with User Defined Function

If you want to extract the second, third or any nth word from the text string, you can create a user defined function to deal with it.

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module window.

Function FindWord(Source As String, Position As Integer)
'Update 20131202
Dim arr() As String
arr = VBA.Split(Source, " ")
xCount = UBound(arr)
If xCount < 1 Or (Position - 1) > xCount Or Position < 0 Then
    FindWord = ""
Else
    FindWord = arr(Position - 1)
End If
End Function

3. Then save the code, in this example, I will get the third word from the string, so type this formula =findword(A2,3) into a blank cell B2, and then drag this cell's AutoFill handle to the range as you need. See screenshot:

Note: In the above formula, A2 is the cell where you want to extract word from, the number 3 indicates the third word in the string that you will extract, and you can change them as you need.


arrow blue right bubble Extract each word from text string and list them horizontally or vertically

This method will introduce Kutools for Excel's Split Cells utility to extract each word from text string cells, and then list extracted words horizontally or vertically based on your need.

Kutools for Excel - Combines more than 300 Advanced Functions and Tools for Microsoft Excel

1. Select the text string cells that you will extract their words, and click the Kutools > Text > Split Cells.

2. In the opening Split Cells dialog box, specify the split type in the Type section, check the Space option in the Specify a separator section, and click the Ok button. See screenshot:
Note: To list all extracted words of each text string cell horizontally, please check the Split to Columns option; to list all extracted words of each text string cells vertically, please check the Split to Rows option. In our case, we check the Split to Rows option.
   

3. In opening new dialog box, select a single cell of range that you will output extracted words into, and click the OK button. See screenshot above:

Then you will see all words are extracted from each text string cell and listing vertically as below screenshot shown:

Checking Split to columns option will horizontally list all extracted words from each text string as below screenshot shown:

Kutools for Excel - Includes more than 300 handy Excel tools. Full feature free trial 60-day, no credit card required! Get it now!


In this Video, the Kutools tab and the Kutools Plus tab are added by Kutools for Excel. If need it, please click here to have a 60-day free trial without limitation!


arrow blue right bubbleRelated articles:


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    murali · 1 years ago
    i want to remove the last word in cell and data is like this "/Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf/Cdtr/CtctDtls/FaxNb" can i have formula
  • To post as a guest, your comment is unpublished.
    John · 1 years ago
    Thanks so much for these! I have a question, though: how do I extract a number or group of numbers from a cell or textbox? For instance, if I have [37.5" x 21'] in cell A1, how could extract 37.5 into A2? There could be any number of characters and numbers in A1, but I'll always want the first number to the left of the "X", and the first number to the right. Not sure if you've covered something like this elsewhere, so I thought I'd ask here.
    (Not sure if this went through the first time, so here it is again.)
  • To post as a guest, your comment is unpublished.
    Antonio · 2 years ago
    Thank you! It works fine called in a Sub.
  • To post as a guest, your comment is unpublished.
    DC2209 · 2 years ago
    the original formula isn't working for me, I keep getting #NAME?, anyone able to help? I am using Excel 2013 and this VBA would save me sooooo much time
  • To post as a guest, your comment is unpublished.
    DC2209 · 2 years ago
    The original VBA code posted here would save me so much time, however whenever I type in the =findword formula, I then get #NAME?, anyone able to help me? I am using Excel 2013