Closed Thread
Results 1 to 24 of 24

VLOOKUP multiple results in a drop down list

  1. #1
    Registered User
    Join Date
    01-23-2009
    Location
    Oregon
    MS-Off Ver
    Excel 2003
    Posts
    35

    VLOOKUP multiple results in a drop down list

    I am using the VLOOKUP function to pull multiple columns of information from another sheet in the same workbook based on a name. The sheet it is pulling from is a query. I am looking up product names, and in the query there may be multiple results that the function can find.

    VLOOKUP only returns the first result that is found. What I am trying to do is get it to dump all the results into a drop down list in one cell. If I attach a drop down to one of the columns of information I am retrieving, then I can select which of the entrys to display, right? I think this should work I just don't know how to go about setting it up to do it.

    How would I set up a VLOOKUP formula that attaches a drop down list containing all the results that the function finds?
    Last edited by tnfire; 02-13-2009 at 05:42 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VLOOKUP multiple results in a drop down list

    Drop down lists that are dynamic like that would need to be created on the sheet somewhere, perhaps in a hidden sheet. You can have a dynamic named range watching the section of formulas creating the list for you from your chosen "category" and providing the drop down functionality.

    If you describe your data set in detail or post an adequate sampling of the data the formulae would need to incorporate, we can offer many possible ways to get this dynamic list created.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    01-23-2009
    Location
    Oregon
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: VLOOKUP multiple results in a drop down list

    Alright, here is my example of what I am trying to do. The 'Cost Per Pound' sheet contains the data (highlighted in green) that is being pulled from the query on the 'Current Inventory' sheet. I have bolded the fields that I want the drop down lists to work with (just the one column, Lot Numbers). Let me know if you have any problems viewing this or if I need to give you any more information. Thanks for the fast response, I appreciate it.
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VLOOKUP multiple results in a drop down list

    Highlight G5 to G25 and type a name into the Name Box just to the left of the formula bar...something like LotNumbers.

    Now you have a named range to use for a Validation list. Go to the cell you want this drop down list to appear in, open up Data > Validation > Allow > List > =LotNumbers.

    All done.
    Last edited by JBeaucaire; 02-12-2009 at 10:15 PM.

  5. #5
    Registered User
    Join Date
    01-23-2009
    Location
    Oregon
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: VLOOKUP multiple results in a drop down list

    Alright, I did things how you explained and it worked for what you were thinking, but I am just not explaining what I need clearly enough.

    H5 is pulling the variety latin name of A5 from a master workbook. Then G5, I5, and J5 are going into the sheet 'Current Inventory' and pulling the top most result of the VLOOKUP for Nemophila menziesii. In 'Current Inventory' there are three different results that could theoretically be pulled for that VLOOKUP on Nemophila menziesii. I want the lot number cell to be a dropdown menu of all the results for Nemophelia menziesii (the three that can be found in 'Current Inventory'). Then I am going to apply that to all of the lot number cells, so each cell has a drop down menu for matching latin names in the 'Current Inventory' sheet.

    I can adjust the I and J columns to pull information based off of the lot number after the change is made. That shouldn't be difficult.

    Let me know if I was unclear. And thanks for responding so quickly last night even though it was late. I left work and was unable to get back in front of a computer to try this out. Let me know what you think.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VLOOKUP multiple results in a drop down list

    Ok, a few tricks needed for this.

    First I've installed a new function called VLOOKUPS. In short, it returns an array of answers the same way VLookup returns a single answer. It's used the same way a VLookup is, except there's only 3 parameters, not 4.

    Next, we have to create a VLOOKUPS list for each of the items in your sheet H5:H25. I put these lists off to the right in columns O:AI. Each column is bringing back an array of matching Lot Numbers for each of the items in H5:H25.

    Now, we need to create a Dynamic Named range for each of the lists in O:AI. I created the first two for you. If you open the Insert>Name>Define>ListH5 you will see that ListH5 is defined as:

    =OFFSET('Cost Per Pound'!$O$1,0,0,MAX(IF(ISNA(MATCH("*",'Cost Per Pound'!$O:$O,-1)),1,MATCH("*",'Cost Per Pound'!$O:$O,-1)),IF(ISNA(MATCH(1E+306,'Cost Per Pound'!$O:$O)),1,MATCH(1E+306,'Cost Per Pound'!$O:$O))))

    So, this formula makes a list of ONLY the cells in column O with values. Blanks are stripped away.

    The formula for ListH6 is similar, it just changes the column references, like so:

    =OFFSET('Cost Per Pound'!$P$1,0,0,MAX(IF(ISNA(MATCH("*",'Cost Per Pound'!$P:$P,-1)),1,MATCH("*",'Cost Per Pound'!$P:$P,-1)),IF(ISNA(MATCH(1E+306,'Cost Per Pound'!$P:$P)),1,MATCH(1E+306,'Cost Per Pound'!$P:$P))))

    Last, in H5, I added the Data > Validation > List =ListH5.

    The first two are done, you can do the remaining Dynamic Name Range definitions and Validation List links.

    In I5, I also created the the INDEX(MATCH() formula to pull over the Common Name. Do the same thing for Inventory Available.
    Attached Files Attached Files
    Last edited by JBeaucaire; 02-13-2009 at 02:16 PM.

  7. #7
    Registered User
    Join Date
    01-23-2009
    Location
    Oregon
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: VLOOKUP multiple results in a drop down list

    I wanted to write you back and tell you thank you. This will take me a bit of time to work through but I'm glad for it because I'll learn about how it functions as I'm doing it. I can tell just by going through it that it is set up exactly how I need it to be.

    The time you and others take in here to help people is commendable. I'll mark this solved once I add everything in and make sure I'm able to get it to work all the way through. Thank you again.

  8. #8
    Registered User
    Join Date
    01-23-2009
    Location
    Oregon
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: VLOOKUP multiple results in a drop down list

    I got it all put together and figured out. It works great and I can't thank you enough.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VLOOKUP multiple results in a drop down list

    Quote Originally Posted by email from Andrew Johnson
    Hey Jerry,

    Ive been trying to work through an example of vlookups that you did in the excel forums and I was wondering how you installed vlookups. I havent been able to figure out how to get it. I'm running excel 2003.
    The code can be found by pressing Alt-F11 to open the VBEditor. You will find a code module with the function code in it.

  10. #10
    Registered User
    Join Date
    10-14-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Smile Re: VLOOKUP multiple results in a drop down list

    Hi Jerry, I know this an old post but I am hoping you can help.

    I am trying to use the function vlookups but I cant seem it to work.
    My example is very easy as attached..

    All i want is if the customer code is found in the right column Q produce a drop down box in D3 with all the notes associated with it.

    so for example for CA21 customer i would expect the notes in the drop down box to be
    gggggggggggggggggggggggggggggggggg
    aaaaaaaaaaaaaaaaaaaa
    bbbbbbbbbbbbbbbbbb
    ccccccccccccccccccccccccc

    I have added your function to the attached excel file but I cant seem to get it to work.

    Can you please provide any help !!!!!!!!!! that would be appreciated.

    Thanks.

    Sam.
    Attached Files Attached Files

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VLOOKUP multiple results in a drop down list

    The VLOOKUPS function is not appropriate for Data Validation exercises. For your need, VBA isn't needed at all.

    I've adjusted your sheet a little to show you how it can be done with some dynamic range formulas and a dynamic DV formula. All you need to do to get it to work is sort the table of values you have off to the right so that all the like values are together in the first column. The dynamic formulas do the rest.

    I also created a dynamic list of account codes that you can then use in column A to keep from having to type.

    Anyway, check it out.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    10-14-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Question Re: VLOOKUP multiple results in a drop down list

    Jerry, thanks very much for your quick reply and your response.

    It is not quiet working for me when I transfer it across to my actual excel file.
    i have now attached my actual file with SHEET1 having the notes and AgeDebDia Sheet being the master file that I want to bring across the notes from SHEET1

    What is the array AccRNG ??
    I cannot see it defined in the excel file you sent back...

    =IF($A2="", Message, INDEX(Notes, MATCH($A2, AccRNG, 0)):INDEX(Notes, MATCH($A2&"z", AccRNG)))

    Does the matching of the customer code have to be in Column A? Would it work if it was in Column B? ie $B2 is in my actual file.

    One last thing if there are NO NOTES available for that customer can the default message be something like "NO NOTES FOUND FOR THIS CUSTOMER"

    that would be better... thanks very much...

    Sam.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    10-14-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Smile Re: VLOOKUP multiple results in a drop down list

    Jerry - I think I have it working.... thanks for you all your help - i renamed the arrays and put it all one one worksheet for the validation to work.

    The only think is how can I if there are NO NOTES available for that customer can the default message be something like "NO NOTES FOUND FOR THIS CUSTOMER"

    Thanks again.

    Sam.

  14. #14
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VLOOKUP multiple results in a drop down list

    Post up what you have so far and point out what you're trying to add.

  15. #15
    Registered User
    Join Date
    10-14-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: VLOOKUP multiple results in a drop down list

    Attached is the file - what i would like is instead of just a blank cell a comment saying "NO NOTES FOR THIS CUSTOMER"

    Ideally i would like it to default to that..... if there are no notes associated.

    Else maybe a comment saying "DROP DOWN FOR NOTES ON THIS CUSTOMER"

    So it will be one or the other... either NO NOTES or DROP DOWN FOR NOTES depending if there are notes or not..

    hope that makes sense... all else is working at the moment...

    Thanks very much.
    Attached Files Attached Files

  16. #16
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VLOOKUP multiple results in a drop down list

    Here you go, I fixed the problems with the formulas that made you move everything to one sheet, too.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    10-14-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: VLOOKUP multiple results in a drop down list

    Jerry, after much headaches I have it working 100% !!

    Thanks for all your help.......... much appreciated.

    Cheers.


  18. #18
    Registered User
    Join Date
    10-27-2010
    Location
    SNG
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: VLOOKUP multiple results in a drop down list

    Quote Originally Posted by JBeaucaire View Post
    Ok, a few tricks needed for this.

    First I've installed a new function called VLOOKUPS. In short, it returns an array of answers the same way VLookup returns a single answer. It's used the same way a VLookup is, except there's only 3 parameters, not 4.

    Next, we have to create a VLOOKUPS list for each of the items in your sheet H5:H25. I put these lists off to the right in columns O:AI. Each column is bringing back an array of matching Lot Numbers for each of the items in H5:H25.

    Now, we need to create a Dynamic Named range for each of the lists in O:AI. I created the first two for you. If you open the Insert>Name>Define>ListH5 you will see that ListH5 is defined as:

    =OFFSET('Cost Per Pound'!$O$1,0,0,MAX(IF(ISNA(MATCH("*",'Cost Per Pound'!$O:$O,-1)),1,MATCH("*",'Cost Per Pound'!$O:$O,-1)),IF(ISNA(MATCH(1E+306,'Cost Per Pound'!$O:$O)),1,MATCH(1E+306,'Cost Per Pound'!$O:$O))))

    So, this formula makes a list of ONLY the cells in column O with values. Blanks are stripped away.

    The formula for ListH6 is similar, it just changes the column references, like so:

    =OFFSET('Cost Per Pound'!$P$1,0,0,MAX(IF(ISNA(MATCH("*",'Cost Per Pound'!$P:$P,-1)),1,MATCH("*",'Cost Per Pound'!$P:$P,-1)),IF(ISNA(MATCH(1E+306,'Cost Per Pound'!$P:$P)),1,MATCH(1E+306,'Cost Per Pound'!$P:$P))))

    Last, in H5, I added the Data > Validation > List =ListH5.

    The first two are done, you can do the remaining Dynamic Name Range definitions and Validation List links.

    In I5, I also created the the INDEX(MATCH() formula to pull over the Common Name. Do the same thing for Inventory Available.
    this is a huge help! i am curious, is there a quicker way to create the vlookups lists? i have about 4000 records that i need to go through. is there something that does that in your 'ArrayFunction.xls'?

  19. #19
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VLOOKUP multiple results in a drop down list

    Please start a thread of your own and attach a sample workbook demonstrating how your need is different. Include a link to this thread if you find it relevant.

    Once your thread is started, feel free to Private message me a link to your new thread.

  20. #20
    Registered User
    Join Date
    07-06-2004
    Posts
    19

    Re: VLOOKUP multiple results in a drop down list

    Hello,

    This is exactly what I was looking for, but unfortunatelly it won't work....
    How do I make an array out of the listH5? I have tried putting the function as such:
    HTML Code: 
    and I get an error : Select at least 68 row(s).
    This is probably due to the fact that the output expects 68 rows, but doesn't know where to put it (array)....



  21. #21
    Registered User
    Join Date
    07-06-2004
    Posts
    19

    Lightbulb Re: VLOOKUP multiple results in a drop down list

    OK go it!

    I needed to define my range as array, meaning selecting relevant range, clicking on formula bar and pressing CTRL+SHIFT+ENTER, and there my array appears!

    Cheers!

  22. #22
    Registered User
    Join Date
    07-14-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VLOOKUP multiple results in a drop down list

    Hoping this is still active!
    I am trying to create a list look up. Example attached:
    Select from Col A one of 8 selections (circuit (list)
    I would like, in adjacent Col (B) another list or chart showing all items/audio type/sig in and sig out based on original circuit selection
    Your help is greatly appreciated!!
    John
    Attached Files Attached Files

  23. #23
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: VLOOKUP multiple results in a drop down list

    Hello gransjo, and welcome to the forum. Unfortunately, you've inadvertently broken a forum rule. Please read the following. Thanks.

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

  24. #24
    Registered User
    Join Date
    07-14-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VLOOKUP multiple results in a drop down list

    Sorry! Will start a new thread!

Closed 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