+ Reply to Thread
Results 1 to 19 of 19

Mulitiple lookups returning value into one cell seperated by commas

  1. #1
    Registered User
    Join Date
    02-29-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    21

    Mulitiple lookups returning value into one cell seperated by commas

    Hi all,

    Been struggling with this for a while (first time post-er as well).

    I have a column of numbers with multiple numbers in each cell (75, 82, 82, 85, 18) and a table which matches those number with what those number refer to. ( 75=Networking, 82=Security, etc.)

    I need to replace the column of numbers with what the numbers equal to while keeping in mind the commas in that cell as well.

    It sounds easy but its a tricky one.

    I have att a sample sheet.

    Any help is appreciated!

    test data.xlsx
    Last edited by jbhamra89; 02-29-2012 at 01:10 PM.

  2. #2
    Registered User
    Join Date
    08-19-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Mulitiple lookups returning value into one cell seperated by commas

    Quote Originally Posted by jbhamra89 View Post

    I need to replace the column of numbers with what the numbers equal to while keeping in mind the commas in that cell as well.
    Will the output look like, for example:

    Networking, Databases, Cloud, DR, Desktop

    In place of the entries in Column A on the Group ID sheet?

    Steve.

    P.S. Welcome to the forum

  3. #3
    Registered User
    Join Date
    02-29-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Mulitiple lookups returning value into one cell seperated by commas

    Correct!

    Thanks for the welcome Steve

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

    Re: Mulitiple lookups returning value into one cell seperated by commas

    I can do it easily if I can use text to columns but I guess you want to keep all the numbers in the same cell?

  5. #5
    Registered User
    Join Date
    02-29-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Mulitiple lookups returning value into one cell seperated by commas

    Hey darknation,

    I also thought of trying text to columns-and it could deff work-however this would be a monthly report and a smoother operation would be needed.

    and yesss all the converted numbers need to be in the same cell separated by commas.

  6. #6
    Registered User
    Join Date
    02-29-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Mulitiple lookups returning value into one cell seperated by commas

    Am I going to have to resort to VBA?

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

    Re: Mulitiple lookups returning value into one cell seperated by commas

    Easiest way would be a while loop but I've never done one in VBA I'm sure someone else can help.

  8. #8
    Registered User
    Join Date
    02-29-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Mulitiple lookups returning value into one cell seperated by commas

    I'll deff look into that then. thanks again

  9. #9
    Registered User
    Join Date
    08-19-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Mulitiple lookups returning value into one cell seperated by commas

    This is doable in VBA, yes - I'm working on that now - I can't see any other way of doing it.

    One "issue" is that the cells in GroupID, Column A are full of loads of spaces after the numbers. Cell A4, for example, is 255 characters long with all the spaces. Is that necessary? It probably isn't a problem, as I'll sift out the whitespace, but it is just a little messy.

    To parse through the string and pull out what precedes a comma, trim that of whitespace then lookup to the Table on Sheet1 is simple enough (he says!). A new string can then be constructed per-cell. This just then needs repeating through all the cells in the initial column.

    Cells like A12 are going to be very long; the output will not be pretty.

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Mulitiple lookups returning value into one cell seperated by commas

    You will need to add a user defined function:

    Add this code to your VB editor (ALT+F11, INSERT, Module)

    Please Login or Register  to view this content.
    Then use formula

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER not just ENTER and copied down.

    Note: if items are not found, nothing will be inserted in the string, so it might be off....
    Last edited by NBVC; 02-29-2012 at 12:55 PM.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  11. #11
    Registered User
    Join Date
    08-19-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Mulitiple lookups returning value into one cell seperated by commas

    ... And, presumably, you don't want the original numbers overtyping? I'll put the character strings into the next column.

  12. #12
    Registered User
    Join Date
    08-19-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Mulitiple lookups returning value into one cell seperated by commas

    Nice one @NBVC!

  13. #13
    Registered User
    Join Date
    02-29-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Mulitiple lookups returning value into one cell seperated by commas

    haha the power of VBA...

    The spaces are not necessary at all, I believe it was just sloppiness of creating the test data on my part.

    I appreciate your help Steve!

    I will deff need to brush up more on VBA

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

    Re: Mulitiple lookups returning value into one cell seperated by commas

    NBVC I have no idea how you knocked that up that fast, Impressive.

  15. #15
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Mulitiple lookups returning value into one cell seperated by commas

    The VBA code is not actually mine... as you will see in the first comment up top (it is one that is popular and is commonly used)

    .... but the formula is mine

  16. #16
    Registered User
    Join Date
    02-29-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Mulitiple lookups returning value into one cell seperated by commas

    NBVC!

    I agree with darknation, I have no idea how you did that so quickly.

    I am trying out the formula as we speak and will let you know the conclusion.

    Thanks for all your help guys

  17. #17
    Registered User
    Join Date
    08-19-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Mulitiple lookups returning value into one cell seperated by commas

    Having a library of code snippets and user defined functions is the way forward!

    Not sure if the aconcat -vs- mconcat may cause a problem? The UDF & cell function seem to have different names?

  18. #18
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Mulitiple lookups returning value into one cell seperated by commas

    Yes, the formula should use ACONCAT... i changed it... MCONCAT is free addin function that I also use.. but it isn't compatible with Excel 2010, i don't think....

    so formula should be:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER

  19. #19
    Registered User
    Join Date
    02-29-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Mulitiple lookups returning value into one cell seperated by commas

    looks like it is starting to work! Thanks a lot for your help everyone.

    -J

+ 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