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.

doc extract before second space 1

Extract text before the second space or comma with formula

Extract text after the second space or comma with formula


arrow blue right bubble 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:

doc extract before second space 2

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))).


arrow blue right bubble 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:

doc extract before second space 3

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...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • 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.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
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.
    Bil1770 · 1 months ago
    In my scenario There are three “-“ and sometimes one “-“
    before second “-“ text should be enter
    if in cell only one “-“ it should be blank

    e.g As-01-14-32 answers like thisAs-01

    e.g As-01 answer Blank cell

    what will be farmula?

    • To post as a guest, your comment is unpublished.
      skyyang · 1 months ago
      Hello, Bil,
      To solve your problem, please apply the below formula:
      =IFERROR(LEFT(A1,FIND("#",SUBSTITUTE(A1,"-","#",2))-1),"")
      Please try it, thank you!

      • To post as a guest, your comment is unpublished.
        Nikhil Jayaswal · 9 days ago
        Hi
        I need help if i want to extract anything after first comma and before last comma.
        "Flat 135 Nevendon Road, Sally,Wickford, SS12 0NL"

        Column A = Flat 135 Nevendon Road
        Column B = Sally,Wickford
        Columns C = SS12 0NL
        • To post as a guest, your comment is unpublished.
          skyyang · 8 days ago
          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)

          Pleasr try, hope it can help you!





      • To post as a guest, your comment is unpublished.
        Bil1770 · 1 months ago
        It’s working, thanks
        • To post as a guest, your comment is unpublished.
          Bil1770 · 1 months ago
          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
          • To post as a guest, your comment is unpublished.
            skyyang · 1 months ago
            Hi,
            May be the below formula can solve your task, please try:
            =IFERROR(TRIM(MID(A1,FIND("#",SUBSTITUTE(A1,"-","#",3))+1,255)),"")
            • To post as a guest, your comment is unpublished.
              Bil1770 · 9 days ago
              Fine thanks
  • To post as a guest, your comment is unpublished.
    Gaby · 3 months ago
    How can I extract Text 1 and Text 2 from a string like Text 1_Text 2_Text 3_Text 4

  • To post as a guest, your comment is unpublished.
    demo · 1 years ago
    how do I do this from right to left. Basically, want to extract last two words.
    • To post as a guest, your comment is unpublished.
      skyyang · 10 months ago
      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)))))

      Please try, hope it can help you!
  • To post as a guest, your comment is unpublished.
    Alessandro · 1 years ago
    THANK YOU!!!
  • To post as a guest, your comment is unpublished.
    Tiki · 1 years ago
    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.
  • To post as a guest, your comment is unpublished.
    archiplanner · 2 years ago
    Hi, is there a way, if I want to select text after 3rd comma from the end?
    • To post as a guest, your comment is unpublished.
      skyyang · 2 years ago
      Hi, Archi,
      To extract all text after the 3rd comma, please apply this formula:
      =RIGHT(A1,LEN(A1)-FIND("@@@",SUBSTITUTE(A1,",","@@@",3)))

      Please try it.
  • To post as a guest, your comment is unpublished.
    Dave · 2 years ago
    =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
    • To post as a guest, your comment is unpublished.
      Ron · 1 years ago
      But this won't work if the text string does NOT always have a second comma...
  • To post as a guest, your comment is unpublished.
    Rodney · 2 years ago
    How would you change this to the 3rd comma? Instead of the 2nd?
    • To post as a guest, your comment is unpublished.
      skyyang · 2 years ago
      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!
      • To post as a guest, your comment is unpublished.
        Tushar · 6 months ago
        Thank you! This was tremendously helpful
  • To post as a guest, your comment is unpublished.
    Guni · 3 years ago
    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.

    Thank you very much.
    • To post as a guest, your comment is unpublished.
      Ritu Garg · 17 days ago
      Hi I am looking for a solution to extract from the below Text , all the text after the second set of digits for example:


      XY limited - UAN#24675 Materials per P/O#75176 Anticon & Sarking and i need only " Anticon & Sarking.