How to extract first two or n words from text string?
If you have a list of text strings which are separated by space, and now, you want to extract first three or n words from the cell value to get the following screenshot result. This article, I will introduce some formulas to extract first two or n words from text string in Excel.
In this example, I will extract first three words from the cell, please apply the following formulas:
Enter any one of the following formulas into a blank cell, C2, for instance, and then drag the fill handle down to the cells that you want to contain this formula, and all the first 3 words have been extracted from the corresponding cells, see screenshot:
=TRIM(LEFT(A2, FIND("~",SUBSTITUTE(A2, " ", "~",3)&"~")))
=LEFT(TRIM(A2),FIND("^",SUBSTITUTE(TRIM(A2)&" "," ","^",3))-1)
Note: If your text strings in column A, and the number of words desired in column B, to extract the different number of first n words, you can apply this formula: =TRIM(LEFT(SUBSTITUTE(A2," ",REPT(" ",1000),B2),1000)), and you will get the following result as you need.
You are guest
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 1 years agoPlay in the sand Felipe if you feel like 5 :)
- To post as a guest, your comment is unpublished.· 1 years agoIt works just fine for me. However, I am trying to understand the logic behind this formula:
=TRIM(LEFT(SUBSTITUTE(A2," ",REPT(" ",1000),B2),1000))
Can somebody please explain it to me like I am 5?