+ Reply to Thread
Results 1 to 8 of 8

Excel 2007 : return multiple values - using vlookup

  1. #1
    Registered User
    Join Date
    07-19-2011
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    19

    return multiple values - using vlookup

    I have a table of data where I want to summarize the data in a matrix type form where it looks up the name of the person and returns all associated IDs with that person, returning more than 1 if that condition exists...

    Attached is a sample of the data and the summary that I was trying to accomplish where you will see my notes on the problem I am having. I am not sure if VLOOKUP is the best formula here and open to other suggestions.

    Thanks!
    Attached Files Attached Files
    Last edited by heatherromo; 03-09-2012 at 12:56 PM.

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

    Re: return multiple values - using vlookup

    Is there always going to be a maximum of 2 matches?
    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.

  3. #3
    Registered User
    Join Date
    07-19-2011
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: return multiple values - using vlookup

    It is possible that there may be more than 2.

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

    Re: return multiple values - using vlookup

    You are going to need VBA then.

    Hit ALT+F11 and then go to Insert|Module and paste the below code in the Editor:

    Please Login or Register  to view this content.
    close the VB editor

    Then in E10 of the spreadsheet enter formula:

    =SUBSTITUTE(TRIM(aconcat(IF($A$2:$A$7=$D10&";"&E$9,$B$2:$B$7,"")," "))," ",", ")

    adjust the ranges to suit your data and then hold the CTRL+SHIFT keys down and hit ENTER, then copy across the columns.

    You will need to widen the columns to see all matches.

  5. #5
    Registered User
    Join Date
    07-19-2011
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: return multiple values - using vlookup

    Is there a simpler solution if there were a max of 2? I am curious

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

    Re: return multiple values - using vlookup

    Not really simpler... just not needing the VBA to consolidate all results...

  7. #7
    Registered User
    Join Date
    07-19-2011
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: return multiple values - using vlookup

    that works...even though I have never used VBA before, I think I have to start learning....Thank you very much

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

    Re: return multiple values - using vlookup

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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