+ Reply to Thread
Results 1 to 4 of 4

Match multiple substrings in a cell against a lookup table and return concatenated values

  1. #1
    Registered User
    Join Date
    05-13-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    2

    Match multiple substrings in a cell against a lookup table and return concatenated values

    Hi,

    I wonder if anyone can help? I'm working with data that needs a complicated lookup and replace. I've tried various versions of vlookup formula but with no luck and was wondering if you guys could help me out?

    I have a column that has comma separated values of text. I need to replace these with different text strings. I have a lookup worksheet with the replacements. If this were a simple one for one lookup it'll be simple with vlookup. But I can't find a way to get it to work with substrings.

    For example, the row may be:

    "^14_eng_6^,^19_ips_3^,^19_ips_7^,^32_uti_3^"

    and I have a lookup worksheet like:

    "^14_eng_6^" : "^C_int_8^"
    "^19_ips_3^" : "^D_abs_6^"
    "^19_ips_7^" : "^C_int_7^"
    "^32_uti_3^" : "^C_int_2^"

    I would want a function that would return a cell value like:

    "^C_int_8^","^D_abs_6^","^C_int_7^","^C_int_2^"


    To make matters worse, the ideal solution would remove any duplication of new values as the lookup table could allow the same result for different lookup values. Eg:

    ^1_eng_7^ : ^C_eng_5^
    ^1_eng_8^ : ^C_eng_5^



    I'll attach a sample document.

    I know it's a bit of a complicated one, but if anybody could point me in the right direction with functions to use, it'll be really, rellay appreciated.

    sample_example.xlsx


    Thanks,
    Steve

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Match multiple substrings in a cell against a lookup table and return concatenated val

    Steve,

    Welcome to the Board.

    Excel is not great when it comes to working with string Arrays so I would suggest you go down the UDF route - one example might be:

    Please Login or Register  to view this content.
    The above would be stored in a Standard Module in VBE - once in place (and file stored as either .xls or .xlsm) you can then use like any other function though macros would need to be enabled - example usage:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    There are numerous approaches to this type of issue -- though 90% will be using VBA for sake of efficiency.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: Match multiple substrings in a cell against a lookup table and return concatenated val

    UDF

    Use in cell like

    =VLookUps(A2,lookups!$A$2:$B$18,2)

    To a standard module
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-13-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Match multiple substrings in a cell against a lookup table and return concatenated val

    Thank you - you are both stars!

    Steve

+ 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