+ Reply to Thread
Results 1 to 6 of 6

Using control toolbox's option buttons to switch between vlookup tables

  1. #1
    Registered User
    Join Date
    05-08-2009
    Location
    Msia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Using control toolbox's option buttons to switch between vlookup tables

    I have 2 vlookup tables (A1:B2) and (A4:B5). The values in each cell are as follows:

    A1=Male
    A2=Female
    B1=Man
    B2=Woman

    A4=Male
    A5=Female
    B4=Bull
    B5=Cow

    Cell A7 is where i will paste either the text "Male" or "Female" into. Cell A8 is where i wish to see the result displayed.

    Question: How do i set up 2 option buttons (available from the control toolbox) with option1 labelled as "Human" and option2 as "Animal", such that:
    - When i select the Human option and paste the text "Male" into cell A7, the result in cell A8 displays "Man"
    Similarly:
    -select Human option, paste "Female", result is "Woman"
    -select Animal option, paste "Male", result is "Bull"
    -select Animal option, paste Female, result is "Cow"

    I'm new to excel's control toolbox, and am only able to implement the first part (the Human part) with vlookup by keying into cell A8 the following:
    =VLOOKUP(A7,$A$1:$B$2,2,FALSE). Basically looking for guidance how to use option buttons to point the vlookup function at the correct table.


    Thank you

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Using control toolbox's option buttons to switch between vlookup tables

    Assuming you linked the 2 option buttons to D1 (Human) and D2 (Animal) then

    =IF(D1,VLOOKUP(A7,A1:B2,2,FALSE),VLOOKUP(A7,A4:B5,2,FALSE))

    or

    =VLOOKUP(A7,CHOOSE(IF(D1,1,2),A1:B2,A4:B5),2,FALSE)
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    05-08-2009
    Location
    Msia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Using control toolbox's option buttons to switch between vlookup tables

    Hi Andy,

    I just realised my error in phrasing the problem using a scenario with 2 tables, resulting in the suggestion using the IF function.

    In actual fact, the scenario i should have described involves at least 3 tables (or more as my situation requires me to be able to make the solution scalable for any number of tables).

    That's why i was thinking perhaps using radio buttons would help simplify matters (e.g. if i have 4 tables, then i can have 4 radio buttons where each radio button corresponds to a different table). Maybe i'm wrong about the IF function not being able to handle this situation neatly, but i'm open to your thoughts please.

    Apologies for the error.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Using control toolbox's option buttons to switch between vlookup tables

    Rather than multiple tables when not have just 1 table with multiple columns.
    So laid out more like this.

    Lookup | Humans | Animals

    Then all you need is way of determining which column in the one table to return the matched value from.

  5. #5
    Registered User
    Join Date
    05-08-2009
    Location
    Msia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Using control toolbox's option buttons to switch between vlookup tables

    Hi Andy,

    What if the lookup variables are not common to the different tables? This is the case in my situation, where only some of the lookup variables are common, but most of the lookup variables are only unique to a particular table.

    (To clarify on what i mean by "lookup variables", they are the "male" and "female" terms which are common to both tables in the scenario presented here).

    Thanks

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Using control toolbox's option buttons to switch between vlookup tables

    Unique lookups would only have a value in the corresponding column.
    So your lookup table may have empty cells in it.

    It would mean you will need individual lists if you were using the lookup column as your data validation list.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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