+ Reply to Thread
Results 1 to 10 of 10

vlookup for multiple entries

  1. #1
    Registered User
    Join Date
    05-28-2006
    Posts
    60

    vlookup for multiple entries

    is there a way i can list all entries that the vlookup looks up? example:

    source:
    1=r
    2=b
    2=c
    3=u
    3=e

    if i do a vlookup to look up "2" it will have "b" and "c" but only "b" will show up since it's the first one. i need to be able to have it as "b ; c" as the output..

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    krayziez,

    This UDF should help.
    If you have 1;2;2;3;3 in A1:A5 and r;b;c;u;e in B1:B5

    =ConcatIf(A1:A10,2,B1:B10,",") will return "b,c" (no quotes)

    The arguments for ConcatIf are modled after SumIf, the compareRange is compared to the Criteria. The string is built from members of the stringsRange. Optional arguments give control of the delimter or adds a NOT to the criteria.

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    05-28-2006
    Posts
    60
    doesn't seem to work.. it says #name?

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    The code should be put in a normal module. (not a sheet's code module or ThisWorkbook).
    If that has been done, try entering it with the Insert Function, under UserDefined, rather than typing it.


    Odd note: Excel's automatic capitalization of a UDF (concatif vs. ConcatIf) is determined by the capitalization entered by the user, the first time that a UDF is entered into a spreadsheet.

  5. #5
    Registered User
    Join Date
    05-28-2006
    Posts
    60
    OK. this line here is red and says Syntax error:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    A thousand apologies, this version has the misplaced parenthesis in the right place.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-11-2007
    Location
    Sweden
    MS-Off Ver
    365
    Posts
    251

    Re: vlookup for multiple entries

    Quote Originally Posted by krayziez View Post
    is there a way i can list all entries that the vlookup looks up? example:

    source:
    1=r
    2=b
    2=c
    3=u
    3=e

    if i do a vlookup to look up "2" it will have "b" and "c" but only "b" will show up since it's the first one. i need to be able to have it as "b ; c" as the output..
    You can create a list without using udf/VBA.

    To lookup the value 2 you can use this formula:
    =INDEX(B1:B8,SMALL(IF(A1:A8=D1,ROW(A1:A8),""),ROW()))

    To remove any errors in the above formula, use this formula:
    =IF(ISERROR(INDEX(B1:B8,SMALL(IF(A1:A8=D1,ROW(A1:A8),""),ROW()))),"",INDEX(B1:B8,SMALL(IF(A1:A8=D1,ROW(A1:A8),""),ROW())))

    See attached workbook.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    03-23-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: vlookup for multiple entries

    Is there a way to list the returned values in columns, rather than in rows. Specifically in the file (lookup_multiple_values.xls that can be downloaded), lets say I want to return all values found for A but lets say that each has a value assigned to it. Can I return the label and it's value?

    Using the example in the spreadsheet, here's how it would look:


    A CAR 50000 Lookup value: A CAR
    B BUS 70000 ROCKET
    C AIRPLANE 2 SHIP
    D HELICOPTER 1
    A ROCKET 0
    C BOAT 50
    A SHIP 0
    B MOTORBIKE

    What I would like to achieve is the above except that it should look like this:

    A CAR 50000 Lookup value: A CAR 50000 ROCKET 0 SHIP 0
    B BUS 70000
    C AIRPLANE 2
    D HELICOPTER 1
    A ROCKET 0
    C BOAT 50
    A SHIP 0
    B MOTORBIKE

    Any help would greatly be appreciated

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,953

    Re: vlookup for multiple entries

    HandsomeDanny,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

  10. #10
    Registered User
    Join Date
    03-23-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: vlookup for multiple entries

    Roger that ! And thanks for the reply

+ 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