+ Reply to Thread
Results 1 to 8 of 8

Extract multiple values from a single value that meet a single search string

  1. #1
    Registered User
    Join Date
    03-28-2012
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2007, 2010
    Posts
    4

    Extract multiple values from a single value that meet a single search string

    Here’s a challenging one I haven’t been able to find on this forum or other sources I’ve scoured.

    I have a text column I need to extract strings from. Each cell may contain zero to fifteen of the strings I need to extract. I’ve tried using & concatenations of text functions MID() and FIND() by increasing the starting increment of the FIND(). However, if subsequent FIND() statements do not have results, it returns #VALUE as expected. Suppose I could nest in IF statements, however the text cell could be up to 5000 characters and contain up to 15 strings for extraction. So, my solution is clunky to say the least.

    In my attached example, you see I’m looking for the string “8000” to fetch the 10-digit 8000 series number. An acceptable solution would only anticipate 15 strings for retrieval. Do need a line-break for further data processing, hence the use of CHAR(10).

    Thanks for taking a look and any suggestions you may have.
    Attached Files Attached Files
    Last edited by njohnson1223; 03-28-2012 at 12:45 PM.

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Extract multiple values from a single value that meet a single search string

    Hi njohnson,

    Welcome to the forum.
    See the attached file, green area which can be dragged towards right side in similar fashion to accommodate more numbers. thanks

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    Attached Files Attached Files
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Registered User
    Join Date
    03-28-2012
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2007, 2010
    Posts
    4

    Re: Extract multiple values from a single value that meet a single search string

    Quote Originally Posted by dilipandey View Post
    Hi njohnson,

    Welcome to the forum.
    See the attached file, green area which can be dragged towards right side in similar fashion to accommodate more numbers. thanks

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    Thanks DILIPandey, great solution. I will need to try out more iterations of the substitute to see if it works for up to 15 strings. I will also need to put my extracted strings in a single column so I will be concatenating the formulas and their results using &CHAR(10).

  4. #4
    Registered User
    Join Date
    03-28-2012
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2007, 2010
    Posts
    4

    Re: Extract multiple values from a single value that meet a single search string

    Although concatenating the formulas into a single cell is giving an circular ref error. Perhaps I'll drag out 15 columns then concatenate the results.

  5. #5
    Registered User
    Join Date
    03-28-2012
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2007, 2010
    Posts
    4

    Re: Extract multiple values from a single value that meet a single search string

    Well, you gave me a great idea. Here was my final solution.

    I first find the first string, then I use search to locate the previous found string plus ten to find the next string. And so on for 15 iterations in columns to the right. Then I concatenate them back into a single cell.

    Only flaw is it returns duplicate results after no further matches on the string since on the next string it will refer to a null and start at the beginning of the cell again. However, this is an acceptable solution as my next step in processing handles the duplicates just fine. One could also use the remove duplcates or write a macro to copy and paste all the values and remove duplicates if they wanted a cleaner look.

    Again, thanks for your help. It was the inspiration to my solution.


    =IFERROR(MID(A4,SEARCH(8000,A4),10),"") {next column} =MID($A4,FIND(8000,$A4,(SEARCH(C4,$A4,1)+10)),10) {next column} =MID($A4,FIND(8000,$A4,(SEARCH(D4,$A4,1)+10)),10) { and so on }
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Extract multiple values from a single value that meet a single search string

    Okay, building on what you guys have already accomplished, this formula in C3 dragged to the right (and down)

    =IF((LEN($A3)-LEN(SUBSTITUTE($A3,"8000","")))/4 < COLUMN(A1),"",MID($A3,FIND(8000,$A3,(SEARCH(B3,$A3,1)+10)),10))
    The first part starts putting blanks into the cells once the # of 8000's in Col A cell is exceeded.
    Hope that helps.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  7. #7
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: Extract multiple values from a single value that meet a single search string

    Did that solution work for you?

  8. #8
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Extract multiple values from a single value that meet a single search string

    Hi njohnson,

    It's good to hear that you are on right track.. and I see that few more forum members are getting interested to this and provided some solution as well.. now did you managed to solve it ?

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

    <click on b

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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