## Extract text before or after second space or comma

If you need to extract the text strings which are before or after the second or nth specific character (space or comma) from a list of cells, this article will introduce some formulas for solving this task in Excel.

#### Extract the text after the second or nth space or comma in Excel

In Excel, the combination of the TRIM, MID, FIND and SUBSTITUTE functions can help you to deal with this task, the generic syntax is:

=TRIM(MID(text,FIND("#",SUBSTITUTE(text," ","#",Nth))+1,255))
• text: The text string or cell reference that you want to extract text from.
• Nth: Represents the space or comma instance number that you want to extract text based on.

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

=TRIM(MID(A2,FIND("#",SUBSTITUTE(A2," ","#",2))+1,255))

##### Explanation of the formula:

SUBSTITUTE(A2," ","#",2): This BUBSTITUTE function is used to find and replace the second space character with # character in cell A2. You will get the result as this: “Insert multiple#blank rows”. This returned result is recognized as the within_text argument in FIND function.

FIND("#",SUBSTITUTE(A2," ","#",2))+1: The FIND function will get the position of the # character within the text string returned by the SUBSTITUTE function, adding 1 means to get the starting position after the second space in text, and you will get 17. The returned result will be recognized as the start_num argument in the MID function.

MID(A2,FIND("#",SUBSTITUTE(A2," ","#",2))+1,255): The MID function is used to extract 255 characters from a text string in cell A2 which start at the number of character returned by the FIND function.

TRIM(): This TRIM function will remove all extra spaces and only leave one between the words.

##### Notes:

1. If your texts are separated by comma or other delimiters, you just need to replace the space string with other separators as you need. Such as:

=TRIM(MID(A2,FIND("#",SUBSTITUTE(A2,",","#",2))+1,255))

2. To extract the text after the nth space, please change the number 2 to the number you need in the formula, for example, to extract the text after the third space, you just need to apply the following formula:

=TRIM(MID(A4,FIND("#",SUBSTITUTE(A4," ","#",3))+1,255))

#### Extract the text before the second or nth space or comma in Excel

To extract the text before the second or nth space or comma, the LEFT, SUBSTITUTE and FIND functions can do you a favor. The generic syntax is:

=LEFT(text,FIND("#",SUBSTITUTE(text, " " ,"#",Nth))-1)
• text: The text string or cell reference that you want to extract text from.
• Nth: Represents the space or comma instance number that you want to extract text based on.

Please copy or enter the below formula into a blank cell:

=LEFT(A2,FIND("#",SUBSTITUTE(A2," ","#",2))-1)

And then, drag the fill handle down to the cells that you want to apply this formula, and all the texts before the second space have been extracted as following screenshot shown

##### Explanation of the formula:

SUBSTITUTE(A2," ","#",2): This BUBSTITUTE function is used to find and replace the second space character with # character in cell A2. You will get the result as this: “Insert multiple#blank rows”. This returned result is recognized as the within_text argument in FIND function.

FIND("#",SUBSTITUTE(A2," ","#",2))-1: The FIND function will get the position of the # character within the text string returned by the SUBSTITUTE function, subtracting 1 to get the position before the second space character in text. And you will get 15. The returned result will be recognized as the num_chars argument in the LEFT function.

LEFT(A2,FIND("#",SUBSTITUTE(A2," ","#",2))-1): At last, the LEFT function is used to extract the leftmost 15 characters returned by the FIND function from the text string in cell A2.

##### Notes:

1. If your texts are separated by comma or other delimiters, you just need to replace the space string with other separators as you need. Such as:

=LEFT(A2,FIND("#",SUBSTITUTE(A2,",","#",2))-1)

2. To extract the text before the nth space, please change the number 2 to the number you need in the formula, for example, to extract the text before the third space, you just need to apply the following formula:

=LEFT(A4,FIND("#",SUBSTITUTE(A4," ","#",3))-1)

#### Relative functions used:

• MID:
• The MID function is used to find and return a specific number of characters from the middle of given text string.
• LEFT:
• The LEFT function extracts the given number of characters from the left side of a supplied string.
• FIND:
• The FIND function is used to find a string within another string, and returns the starting position of the string inside another one.
• SUBSTITUTE:
• The Microsoft Excel 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.

#### More articles:

• Extract Multiple Lines From A Cell
• If you have a list of text strings which are separated by line breaks (that occurs by pressing Alt + Enter keys when entering the text), and now, you want to extract these lines of text into multiple cells as below screenshot shown. How could you solve it with a formula in Excel?
• Extract Nth Word From Text String In Excel
• If you have a list of text strings or sentences, now, you want to extract the specific nth word from the list as below screenshot shown. This article, I will introduce some methods for solving this job in Excel.
• 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 Substring From Text String In Excel
• It may be a common task for you that you need to extract substrings from text strings, in Excel, there is not a direct function for doing this, but, with the help of the LEFT, RIGHT, MID and SEARCH functions, you can extract kinds of substrings as you need.

### The Best Office Productivity Tools

#### Kutools for Excel - Helps You To Stand Out From Crowd

 🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions… Popular Features: Find, Highlight or Identify Duplicates  |  Delete Blank Rows  |  Combine Columns or Cells without Losing Data  |  Round without Formula ... Super VLookup: Multiple Criteria  |  Multiple Value  |  Across Multi-Sheets  |  Fuzzy Lookup... Adv. Drop-down List: Easy Drop Down List  |  Dependent Drop Down List  |  Multi-select Drop Down List... Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Columns to Select Same & Different Cells ... Featured Features: Grid Focus  |  Design View  |  Big Formula Bar  |  Workbook & Sheet Manager | Resource Library (Auto Text)  |  Date Picker  |  Combine Worksheets  |  Encrypt/Decrypt Cells  |  Send Emails by List  |  Super Filter  |  Special Filter (filter bold/italic/strikethrough...) ... Top 15 Toolsets:  12 Text Tools (Add Text, Remove Characters ...)  |  50+ Chart Types (Gantt Chart ...)  |  40+ Practical Formulas (Calculate age based on birthday ...)  |  19 Insertion Tools (Insert QR Code, Insert Picture from Path ...)  |  12 Conversion Tools (Numbers to Words, Currency Conversion ...)  |  7 Merge & Split Tools (Advanced Combine Rows, Split Excel Cells ...)  |  ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

#### 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, Edge and Firefox.