+ Reply to Thread
Results 1 to 12 of 12

Excel 2007 : Vlookup returns multiple values in Dropdown

  1. #1
    Registered User
    Join Date
    07-15-2004
    Posts
    7

    Vlookup returns multiple values in Dropdown

    Hello All,

    I have a sheet where I have names of cities in B2 (in a dropdown) & in sheet 2 I have all equipments in those cities. What I want to do is when I select City from Sheet1 (B2) it should give me corresponding values from Sheet 2 in Sheet 1 B2 in a dropdown box. I use vlookup but it gives me first value. What I want is all values corresponding to the city in dropdown
    Sheet1 looks like this
    A B
    1 City (Names of all Cities in dropdown)
    2 Equipment (should give me corresponding values from sheet 2 in dropdown)

    Sheet2 looks like this
    A B
    1 New York Drive
    2 Alaska RAM
    3 New York CPU
    4 New Jersey Monitor
    5 New Jersey Floppy drive.
    Attached Files Attached Files
    Last edited by arv1980; 06-12-2010 at 12:44 AM.

  2. #2
    Registered User
    Join Date
    06-08-2010
    Location
    Helsingborg, SWEDEN
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    18

    Re: Vlookup returns multiple values in Dropdown

    Like this?! (see attachment)
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-15-2004
    Posts
    7

    Re: Vlookup returns multiple values in Dropdown

    Thanks Henrikoz.
    This is not exactly what I am looking for. That is the one I already have done. What I want is, if you check Alaska it has 3 values (Floppy drive, Monitor and RAM). So when I select Alaska from dropdown in sheet1 it should display all 3 values in B2 of sheet1(it has to lookup those values from sheet 2) and so on.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Vlookup returns multiple values in Dropdown

    Try this in the worksheet module for Sheet1
    Please Login or Register  to view this content.

    I have also made a few other changes to your original sample (demo file attached to this post)

    Validation of other cells are now from Sheet2 and called using named range "State" this list is dynamic so you can add or subtract from it as you wish

    You should consider doing the same with your list of equipment.

    Hope this helps.

    If you need any further information, please feel free to ask further

    However

    If this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody!
    Also
    If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.


    Tips:-
    1/. Add a location to your profile, it helps with prioritising replies according to time zones and any possible language interpretation problems.

    2/. Add the version of Excel you are using there are significant differences between them and it helps to know when answering problems.
    Attached Files Attached Files
    Last edited by Marcol; 06-10-2010 at 06:08 AM. Reason: Error in DynamicList formula

  5. #5
    Registered User
    Join Date
    07-15-2004
    Posts
    7

    Re: Vlookup returns multiple values in Dropdown

    Thanks a lot Marcol. I am trying to use the code in my original workbook but for some reason the worksheet change code is not getting fired immaterial of what I do on worksheet. I tried to put the code in Myworkbook and also in sheet that I am using but no good. There are many sheets in the workbook and the worksheet I want to use is the second sheet named WUG and have saved it as Xlsm file. I dont know if that makes any difference & what going wrong. I am new to vba please let me know what is wrong.

  6. #6
    Registered User
    Join Date
    07-15-2004
    Posts
    7

    Re: Vlookup returns multiple values in Dropdown

    Hi Marcol, I figured it out and got it working. I cannot thank you enough for this. I really don't have words to thank you. You are fabulous.

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Vlookup returns multiple values in Dropdown

    Happy to have helped.

    Sorry I missed your post #5, I'm working away from home at present and have limited Internet access.

    Look at the tips at the end of post # 4, it can help to avoid a few problems with communication.

    Cheers

  8. #8
    Registered User
    Join Date
    07-15-2004
    Posts
    7

    Re: Vlookup returns multiple values in Dropdown

    Hi Marcol,

    For some reason the code has stopped working again like in the example if I select the state then it does not gives me the component. Also at times when I select some state it goes to the lookup sheet(does not happens everytime). The Worksheet_Change event does not fires at all.

    This is my original code
    Please Login or Register  to view this content.
    Thanks,

    Amit
    Last edited by arv1980; 06-28-2010 at 10:59 AM.

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Vlookup returns multiple values in Dropdown

    Please wrap your code in code tags, before the moderators get you...

    Forum rules
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button.
    Do this first then post your workbook or sample so it can be checked.
    The code I gave you seems to work , so it must be your addapted caoe that has the problem.


    Cheers
    Last edited by Marcol; 06-28-2010 at 07:08 AM.

  10. #10
    Registered User
    Join Date
    07-15-2004
    Posts
    7

    Re: Vlookup returns multiple values in Dropdown

    Yes your code works absolutely fine...even my code worked for couple of days and then all of sudden it stopped working. I did not make any changes. Also I could not send the workbook as I have some company related information in it which I cant share. Any guess what might be causing issue. The worksheet_Change event does not triggers at all immaterial of what I do.

  11. #11
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Vlookup returns multiple values in Dropdown

    If you have run any other code it is possible that that Application.EnableEvents has been turned off and not subsequently reset.

    With the offending workbook open

    Try in the immediate pane of the VBa editor
    Please Login or Register  to view this content.
    press return
    if this returns False
    Enter this line
    Please Login or Register  to view this content.
    press return
    This will reset the Events Procedure

  12. #12
    Registered User
    Join Date
    04-16-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Excel 2007 : Vlookup returns multiple values in Dropdown

    Hi Marcol and community. I would like to seek your help about this file. I'm actually in the same situation in using drop downs like this and I'm trying to follow the file but cannot get it to working.

    Any help would be appreciated! Thanks!

    Here is what I did - I downloaded the test file and used the VB code Marcol has provided. Is there anything else that I would need to do?

+ 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