Log in  \/ 
x
or
x
x
Register  \/ 
x

or

Extract word which containing specific text in Excel

Sometimes, you may want to extract the word from a cell that contains a specific character or text, such as following screenshot shown, to extract all words that containing the “=” character. How could you solve this task in Excel?


Extract word which containing a specific character or text

To solve this problem, you should create a formula which combines the TRIM, MID, SUBSTITUTE, REPT, MAX and FIND functions. The generic syntax is:

=TRIM(MID(SUBSTITUTE(string," ",REPT(" ",99)),MAX(1,FIND(char,SUBSTITUTE(string," ",REPT(" ",99)))-50),99))
  • string: The text string or cell value that you want to extract word inside.
  • char: The character or text that you want to extract word contains.

1. Please enter or copy the following formula into a blank cell where you want to get the result:

=TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",99)),MAX(1,FIND("=",SUBSTITUTE(A2," ",REPT(" ",99)))-50),99))

2. Then, drag and copy the formula to the cells that you want to use, and you will get the following result:


Explanation of the formula:
  • SUBSTITUTE(A2," ",REPT(" ",99)): This SUBSTITUTE function will replace each single space with 99 spaces which are returned by the REPT function, and get a new text string with multiple spaces between each word. The number 99 is just an arbitrary number that represents the longest word you need to extract.
  • FIND("=",SUBSTITUTE(A2," ",REPT(" ",99)))-50: This FIND function is used to find the position of the first specific character (in this case, “=”) inside the new text string returned by the SUBSTITUTE function.
  • MAX(): If the substring appears in the front of the text string, the FIND function will get a negative number, and this MAX function is used to reset the negative value to 1.
  • MID(SUBSTITUTE(A2," ",REPT(" ",99)),MAX(1,FIND("=",SUBSTITUTE(A2," ",REPT(" ",99)))-50),99): This MID function is used to extract 99 characters from the text string which is returned by the SUBSTITUTE function at a specific position that returned by the FIND function.
  • TRIM(): This TRIM function removes all extra spaces from text string returned by the MID function.

Notes:

1. In the above formula, you can change the “=” character to any other character or text you need.

2. If there are multiple words which contain the specific character, only the first word will be extracted.


Relative functions used:

  • REPT:
  • The REPT function is used to repeat the characters a specified number of times.
  • SUBSTITUTE:
  • The SUBSTITUTE function replaces text or characters within a text string with another text or characters.
  • TRIM:
  • The TRIM function removes all extra spaces from text string and only keeps single spaces between words.
  • MID:
  • The MID function returns the specific characters from the middle of text string.
  • MAX:
  • The MAX function returns the largest numeric value in a range of values.

More articles:

  • Extract Text Between Parentheses From Text String
  • If there is part of the text surrounded with the parentheses within the text string, now, you need to extract all the text strings between the parentheses as following screenshot shown. How could you solve this task in Excel quickly and easily?
  • Extract Last Line Of Text From A Multi-Line Cell
  • To extract the last line of text from a text string which is separated by line breaks, normally, there is no direct way for you to solve this. This article, I will introduce a formula to deal with this task in Excel.

The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.