+ Reply to Thread
Results 1 to 13 of 13

Returning data from a dropdown box using vlookup

  1. #1
    Registered User
    Join Date
    06-03-2013
    Location
    Urbana, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    57

    Returning data from a dropdown box using vlookup

    Greetings,

    I have two dropdown boxes. The first one has a list of jobs. Once you select a job the second dropdown box will populate a list of fields for that job even though all the fields are the same for each job. When I select a field from second dropdown box I want to be able to populate a cell with a candidate for that field. For instance. If I select Job1 then select Field1 I want it to return Person1 in a given cell. Job1 then field2 then Person2. Job1 then field3 then Person3 and so on. I have attached a sample workbook as a simplfied example. It contain two sheets.

    Thank you

    SampleWorkbook.xlsx

  2. #2
    Registered User
    Join Date
    06-03-2013
    Location
    Urbana, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Returning data from a dropdown box using vlookup

    bump......

  3. #3
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Returning data from a dropdown box using vlookup

    See the attached
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-03-2013
    Location
    Urbana, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Returning data from a dropdown box using vlookup

    Alright is there anyway to return a textbox of information rather than populating a cell. Instead return a textbox thats says person1, person2, and so on.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Returning data from a dropdown box using vlookup

    If the fields are the same for each job then you can redesign your table to look like this...

    J = Job
    F = Field
    P = Person

    ......F1.....F2.....F3
    J1...P1.....P2.....P3
    J2...P4.....P5.....P6
    J3...P7.....P8.....P9

    I redefined all the named ranges and this is the resulting formula:

    =VLOOKUP(A1,JobTable,MATCH(A5,Fields,0)+1,0)

    Here's your file with this new design.

    SampleWorkbook(1).xlsx
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    06-03-2013
    Location
    Urbana, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Returning data from a dropdown box using vlookup

    Ok cool. could you explain in the vlookup formula what the last few numbers are referring to?

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Returning data from a dropdown box using vlookup

    =VLOOKUP(A1,JobTable,MATCH(A5,Fields,0)+1,0)

    MATCH(A5,Fields,0)

    The 0 means to find an "exact" match of cell A5 (case is not a factor).

    MATCH(A5,Fields,0)+1

    The +1 is an "offset correction". The MATCH function will return a number from 1 to 3 but we need these numbers to be from 2 to 4 (the relative column numbers of the table).

    =VLOOKUP(A1,JobTable,MATCH(A5,Fields,0)+1,0)

    The 0 means to find an "exact" match of cell A1 (case is not a factor).

  8. #8
    Registered User
    Join Date
    06-03-2013
    Location
    Urbana, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Returning data from a dropdown box using vlookup

    alright its not working for the actual database ive been buildng so Im going to attach another sample workbook that is much more direct of the design i have. Would you be able to construct the formula to make it work in this sample? I would greatly appreciate it.

    SampleWorkbook2.xlsx

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Returning data from a dropdown box using vlookup

    One thing you have to correct is the source for the drop down in cell A5.

    Excel won't allow you to use the names from the drop down in cell A2 because they are also valid cell references. For example, Job1 is a valid cell address (column JOB, row 1). When this happens Excel concatenates an underscore to the string:

    _Job1

    This tells Excel that the string is not a cell reference.

    So, for the drop down list source in cell A5 use:

    =INDIRECT("_"&A2)

    Ok, so what result are you looking for? Do you want to return the column headers based on the selections of the drop down lists?

    If I select Job2 in A2 and Person2 in A5 what result do you expect?

  10. #10
    Registered User
    Join Date
    06-03-2013
    Location
    Urbana, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Returning data from a dropdown box using vlookup

    I made a mistake. I validated the second dropdown box incorrectly. Now i have it to return a list of fields. Then I want to populate a cell so that when you select a field from the second dropdown box it will return a person.
    Attached Files Attached Files

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Returning data from a dropdown box using vlookup

    OK, here's the formula using cell addresses instead of named ranges.

    =VLOOKUP(A2,ControlInterface!A:J,MATCH(A5,ControlInterface!A1:J1,0),0)

  12. #12
    Registered User
    Join Date
    06-03-2013
    Location
    Urbana, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Returning data from a dropdown box using vlookup

    excellent thank you very much!

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Returning data from a dropdown box using vlookup

    You're welcome. Thanks for the feedback!

+ 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