How to extract text before / after the second space or comma in Excel?

In Excel, the Text To Columns function may help you to extract each text from one cell into separate cells by space, comma or other delimiters, but, have you ever tried to extract the text before or after the second space or comma from a cell in Excel as following screenshot shown? This article, I will talk about some methods to deal with this task.

Extract text before the second space or comma with formula

To get the text before the second space, please apply the following formula:

Enter this formula: =IF(ISERROR(FIND(" ",A2,FIND(" ",A2,1)+1)),A2,LEFT(A2,FIND(" ",A2,FIND(" ",A2,1)+1))) into a blank cell where you want to locate the result, C2, for example, and then drag the fill handle down to the cells that you want to contain this formula, and all the text before the second space has been extracted from each cell, see screenshot:

Note: If you want to extract the text before the second comma or other separators, please just replace the space in the formula with comma or other delimiters as you need. Such as: =IF(ISERROR(FIND(",",A2,FIND(",",A2,1)+1)),A2,LEFT(A2,FIND(",",A2,FIND(",",A2,1)+1))).

Extract text after the second space or comma with formula

To return the text after the second space, the following formula can help you.

Please enter this formula: =MID(A2, FIND(" ", A2, FIND(" ", A2)+1)+1,256) into a blank cell to locate the result, and then drag the fill handle down to the cells to fill this formula, and all the text after the second space has been extracted at once, see screenshot:

Note: If you want to extract the text after the second comma or other separators, you just need to replace the space with comma or other delimiters in the formula as you need. Such as: =MID(A2, FIND(",", A2, FIND(",", A2)+1)+1,256).

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...

Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...

Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...

Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...

Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...

Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...

Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...

More than 300 powerful features. Supports Office/Excel
2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features
30-day free trial. 60-day money back guarantee.

I have the text like this LAXMI RANI DELHI DELHI CG012054567IN CA so, I want the text to be arranged in excel like this LAXMI RANI(1st cell ) DELHI(2nd cell) DELHI (3rd cell) CG012054567IN (4th cell) CA(5th cell)

To deal with your problem, first, you can split your cell values based on space by using the Text to Columns feature, after spliting the text strings, you just need to combine the fisrt two cell values as you need.

Hello, Jayaswal, To solve your porblem, please apply the following formulas: First part--Cell B1: =LEFT(A1,FIND(",",A1,1)-1) Second part--Cell C1: =MID(A1,FIND(",",A1)+1,LOOKUP(1,0/(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)=","),ROW(INDIRECT("1:"&LEN(A1))))-FIND(",",A1)-1) Third part--Cell D1: =MID(A1,FIND("=",SUBSTITUTE(A1,",","=",LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))+1,256)

One more thing after third”-“all text should remain even 1 or 10 otherwise blank e.g A-01-12-As answer As e.g A-01-12-Asty answer Asty e.g A-01 answer blank

Hi, demo,
To extract and return the last two words from text strings, please apply the below formula:
=IF((LEN(A1)-LEN(SUBSTITUTE(A1," ","")))<2,A1,RIGHT(A1,LEN(A1)-FIND("/",SUBSTITUTE(A1," ","/",(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-1)))))

Is there a way to extract various pieces of this string? 123ABC.01.02.03.04 ---- for example, to pull the 123ABC, and then in the next column pull 123ABC.01, and then 123ABC.01.02, then 123ABC.01.02.03, and so on.

=IF(ISERROR(FIND(",",A2,FIND(",",A2,1)+1)),A2,LEFT(A2,FIND(",",A2,FIND(",",A2,1)+1)))
That will return all text left of the second comma plus the second comma. This should be

=IF(ISERROR(FIND(",",A2,FIND(",",A2,1)+1)),A2,LEFT(A2,FIND(",",A2,FIND(",",A2,1)+1)-1))
to omit the second comma

1. Saquon Barkley, RB, Penn State
2. Derrius Guice, RB, LSU
3. Sony Michel, RB, Georgia
4. Ronald Jones II, RB, USC
5. Nick Chubb, RB, Georgia

Bad:
1. Saquon Barkley, RB,
2. Derrius Guice, RB,
3. Sony Michel, RB,
4. Ronald Jones II, RB,

Better:
1. Saquon Barkley, RB
2. Derrius Guice, RB
3. Sony Michel, RB
4. Ronald Jones II, RB

Hello,Rodney,
To extract the text before the 3rd space, please apply this formula:
=IF(ISERROR(FIND(" ",A2,FIND(" ",A2,FIND(" ",A2,1)+1) +1)),A2,LEFT(A2,FIND(" ",A2,FIND(" ",A2,FIND(" ",A2,1)+1) + 1)));
To extract the text after the 3rd space, please use this formula:
=MID(A2, FIND(" ", A2,FIND(" ", A2, FIND(" ", A2)+1) +1)+1,30000)
Please try it, hope it can help you!
Thanks!

Hi, this formula will be ideal for but instead of removing text after second space i want remove everything after 3rd i have been trying insert 3rd FIND(" ",A2 i understand that the formula itself is =FIND(" ",X13,1). can you please help me out. I am not good with nesting the formulas.