+ Reply to Thread
Results 1 to 8 of 8

Finding a substring within a string

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Finding a substring within a string

    I have a spreadsheet I received from one of my suppliers that has about 2500 rows. Rather than separating the relevant data for each product, they put it all in a single column of cells marked "description".

    Here's a typical example:

    HANDLE SPRINGS ZN MATT NICKEL M4 CTC 128MM

    What I want to do is analyze the contents and see if it contains a certain sub-string. If it finds it, I'd like to consult a V Look-up table so that it will return the term I want.

    The sub-strings I'm looking for are "ZN", "AL", or "ORB". So in the above example, the function would find "ZN", and then go to the V look up table, returning the final value of "Zinc".

    Any help greatly appreciated!

  2. #2
    Registered User
    Join Date
    12-30-2011
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Finding a substring within a string

    Hi there,

    Not particularly elegant, but if it is only the three values you're looking for you could use this formula:

    =IF(ISNUMBER(SEARCH("ZN",A1)),"Zinc",IF(ISNUMBER(SEARCH("AL",A1)),"Aluminium",IF(ISNUMBER(SEARCH("ORB",A1)),"Orbitinium")))

    Just change A1 to the cell with the description in and the "Zinc","Aluminium" and "Orbitinium" (everyone's favourite fictional element!) to whatever you need. Drag down!

    HTH,

    FermentedR

  3. #3
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Finding a substring within a string

    Thanks! That did work, and I hate to look a gift horse in the mouth, but I have to confess that to keep the example brief I didn't say that there could be more than the 3 possibilities I cited. From what I can see there could be as many as 7, perhaps more, so I'd love to keep the formula as simple as possible.

    Is there a way to perform the task with a V look-up table? This way once the formula is in and copied, it's easy to change the sub-string I'm looking for and it's result as well.

  4. #4
    Registered User
    Join Date
    12-30-2011
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Finding a substring within a string

    Hi there,

    OK - here's an example that will work. Obviously change the lookup values in the I:J table. This is an array formula so once you've copied it in you'll have to press CTRL+SHIFT+ENTER for it to work.

    It's a little complicated - basically, it's using an INDEX/MATCH to extract the reference in the lookup table, then this is nested within a VLOOKUP.

    Hope that solves it!

    Cheers,

    FermentedR
    Attached Files Attached Files
    Last edited by Fermented Reptile; 02-21-2013 at 12:56 PM. Reason: Initial error

  5. #5
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    wales
    MS-Off Ver
    Excel 2007
    Posts
    964

    Re: Finding a substring within a string

    nevermind its already solved.
    Last edited by twiggywales; 02-21-2013 at 12:59 PM.
    The Importance of INDEX - A GUIDE TO INDEX'S OTHER USES
    <--- If a post helps hit the star

  6. #6
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Finding a substring within a string

    See attached. I "expanded" (to put it mildly) your solution. As it turned out, the original manager didn't keep his naming conventions as consistent as he could have, so each variation needed a new entry.

    Sheet 2 has the V look up table

    Thanks for having a look!
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Finding a substring within a string

    Sweet!!!!!

    Because the site was having server issues today I didn't even realize you had posted a solution to my problem.

    A HUGE Thank you!!!!!

  8. #8
    Registered User
    Join Date
    01-30-2013
    Location
    Long Island NY
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Finding a substring within a string

    Sweet!!!!!

    Because the site was having server issues today I didn't even realize you had posted a solution to my problem.

    A HUGE Thank you!!!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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