+ Reply to Thread
Results 1 to 9 of 9

Extract text from cell with delimiters

Hybrid View

  1. #1
    Registered User
    Join Date
    02-22-2012
    Location
    UK
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    25

    Extract text from cell with delimiters

    I am trying to extract a specific text from a cell with text up to the first delimiter from its left i.e.

    (Green Tuesday)-(Yellow Monday)-(Black Friday)(Sunny Sunday)-(Purple Wednesday)

    I would like to search for '(Sunny Sunday)' and the text up to the first delimiter ('-') from its left so resulting in

    (Black Friday)(Sunny Sunday)

    I have searched here but could not find anything that fit my query.

    Thanks

  2. #2
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Extract text from cell with delimiters

    Hi

    in Excel 2003 you could try
    =MID(A1,LARGE(IF(MID(A1,ROW(A$1:A$200),1)="-",ROW(A$1:A$200)),2)+1,LARGE(IF(MID(A1,ROW(A$1:A$200),1)="-",ROW(A$1:A$200)),1)-LARGE(IF(MID(A1,ROW(A$1:A$200),1)="-",ROW(A$1:A$200)),2)-1)

    to be confirmed with control+shift+enter
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    02-22-2012
    Location
    UK
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    25

    Re: Extract text from cell with delimiters

    Quote Originally Posted by canapone View Post
    Hi

    in Excel 2003 you could try
    =MID(A1,LARGE(IF(MID(A1,ROW(A$1:A$200),1)="-",ROW(A$1:A$200)),2)+1,LARGE(IF(MID(A1,ROW(A$1:A$200),1)="-",ROW(A$1:A$200)),1)-LARGE(IF(MID(A1,ROW(A$1:A$200),1)="-",ROW(A$1:A$200)),2)-1)

    to be confirmed with control+shift+enter
    Hi thanks, this one does not seem to work for me, as I need to find specific text first then get text up to that delimiter.

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extract text from cell with delimiters

    Try this
    Assuming text string is in A1
    Enter in B1
    Formula: copy to clipboard
    =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("(Sunny Sunday)",A1)+LEN("(Sunny Sunday)")-1),"-",REPT(" ",255)),255))


    A
    B
    1
    (Green Tuesday)-(Yellow Monday)-(Black Friday)(Sunny Sunday)-(Purple Wednesday) (Black Friday)(Sunny Sunday)
    Sheet: Sheet1
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Registered User
    Join Date
    02-22-2012
    Location
    UK
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    25

    Re: Extract text from cell with delimiters

    Quote Originally Posted by AlKey View Post
    Try this
    Assuming text string is in A1
    Enter in B1
    Formula: copy to clipboard
    =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("(Sunny Sunday)",A1)+LEN("(Sunny Sunday)")-1),"-",REPT(" ",255)),255))


    A
    B
    1
    (Green Tuesday)-(Yellow Monday)-(Black Friday)(Sunny Sunday)-(Purple Wednesday) (Black Friday)(Sunny Sunday)
    Sheet: Sheet1
    Hi, many thanks for this, this appears to do what I am looking for

  6. #6
    Registered User
    Join Date
    02-22-2012
    Location
    UK
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    25

    Re: Extract text from cell with delimiters

    This does not work for cells which contains around 6000 characters.

    I have tried to tweak the REPT numbers i.e. 4000,4000 but this may work for some cells (sometimes go past the first delimiter to another), and some will give an #VALUE error.

    Is there anything else I should try?

    Thanks again.

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extract text from cell with delimiters

    Quote Originally Posted by GreenWheels View Post
    This does not work for cells which contains around 6000 characters.

    I have tried to tweak the REPT numbers i.e. 4000,4000 but this may work for some cells (sometimes go past the first delimiter to another), and some will give an #VALUE error.

    Is there anything else I should try?

    Thanks again.
    You should've mentioned about this earlier.
    Try this
    Formula: copy to clipboard
    =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("(Sunny Sunday)",A1)+LEN("(Sunny Sunday)")-1),"-",REPT(" ",LEN(A1))),LEN(A1)))

  8. #8
    Registered User
    Join Date
    02-22-2012
    Location
    UK
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    25

    Re: Extract text from cell with delimiters

    Quote Originally Posted by AlKey View Post
    You should've mentioned about this earlier.
    Try this
    Formula: copy to clipboard
    =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("(Sunny Sunday)",A1)+LEN("(Sunny Sunday)")-1),"-",REPT(" ",LEN(A1))),LEN(A1)))
    Tried this, and still some values outstanding with #VALUE!

    This relates to text which '(Sunny Sunday)" has a hit somewhere in middle of text (6000 chars) and its first delimiter is around 1200 chars away - hope this makes sense to you?

    Thanks

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extract text from cell with delimiters

    There is a problem with the data quality/inconsistency that would make formula to fail. Unfortunately, I don't have any other solutions.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 07-20-2016, 03:52 AM
  2. [SOLVED] Extract string between delimiters
    By Apexeon in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-27-2015, 06:23 PM
  3. Replies: 2
    Last Post: 04-09-2014, 11:48 AM
  4. separating text from numbers in one cell with no delimiters
    By mandy.mcdonough in forum Excel General
    Replies: 4
    Last Post: 04-03-2012, 04:49 PM
  5. VBA splitting Text with Delimiters?
    By Irish RayRay in forum Excel General
    Replies: 6
    Last Post: 03-14-2012, 12:54 PM
  6. Text to Column delimiters
    By sapling in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-20-2010, 04:48 PM
  7. [SOLVED] Extract based on Delimiters
    By ssjody in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-26-2005, 11:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1