+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: Using IF/VLOOKUP formulas INSIDE Data Validation

  1. #1
    Registered User
    Join Date
    09-01-2011
    Location
    Blythe, AZ
    MS-Off Ver
    Excel 2003
    Posts
    13

    Exclamation Using IF/VLOOKUP formulas INSIDE Data Validation

    Hello there everyone.

    I've been having a whopper of a problem and for the life of me, I can't figure it out. Hopefully someone out there in the Excel Forum universe can help alleviate my dilemma.

    What I have attached is spreadsheet I've built to help quickly generate an army list for a tabletop game. Anyone can click on the Force Organization Slot (FOS) and choose the type of unit and from there, select the specific unit name attached to that FOS. Each individual unit has a list of options/upgrades currently attached to the sheet from cells AD through AX and the points cost listed next to each upgrade.

    For example, when selecting the Rhino unit from the Dedicated_Transport FOS, there should be 4 drop down lists of selectable upgrades (Storm Bolter, Hunter-Killer Missile, Dozer Blade, and Extra Armor). Currently, I have only named the ranges for the Rhino and Razorback units in order to get this working properly without having to go through the entire list of units and change names/create ranges/ect.

    What I'm aiming to do is to create an individual drop down list that is directly related to the Unit Name cell in order to populate a complete and selectable upgrade list for each unit. I have played around with some functions that work in the spreadsheet (see cells X10:X12) but do not work properly with Data Validation.

    Oddly enough, when I enter this formula under Data Validation:

    =IF($A$3<>$AD$1:$AD$182,VLOOKUP(A3,Options,2,FALSE),"")

    I do not get an error, yet the drop down list does not allow me to select anything as I thought it would.

    Any help or insight into this problem would be highly appreciated. If at all possible, I'd like to try to avoid using VBA but I wouldn't be opposed to using small macros (I've never worked with either before).

    Thanks in advance!
    Attached Files Attached Files
    Last edited by NBVC; 09-07-2011 at 06:53 PM.

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,608

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    Using a data validation formula like this:

    =OFFSET(INDIRECT($A$3),0,1,1,COUNTA(INDIRECT($A$3)))

    will get you all the items in that named range.... you won't be able to get just the text strings from those ranges though. You would need to create subsets in the sheet of each of those ranges, and reference those instead, if that is what you need.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Registered User
    Join Date
    09-01-2011
    Location
    Blythe, AZ
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    Thanks for the quick reply.

    I have tried the offset formula to see if I could get the lists to work but it's not exactly what I'm looking for. Each set of options needs to be dynamic to the unit that is selected (which is why I've separated them into columns/rows). Some units have more options than others and some may have none. It is vital that each individual unit has a dynamic list of options and upgrades upon selection.

    The numbers on each of the options is something to be used afterwards (a simple vlookup formula in the points column) but this is just one bump in the road I can't seem to get over.

  4. #4
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,608

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    The formula I gave is dependent on the option selected in A3. So if you select Rhino in A3, the options in the dropdown get updated to reference the Rhino named range.

    Not sure what you mean otherwise? Can you give definite example situation and outcome expected?
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  5. #5
    Registered User
    Join Date
    09-01-2011
    Location
    Blythe, AZ
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    Thanks again for the quick reply. To go into the example deeper, let's take a look at the Rhino once more.

    Once the Rhino is selected as a unit, 4 distinct upgrades should appear in the Options drop down menu (Storm Bolter, Hunter-Killer Missile, Dozer Blade, and Extra Armor). Each individual upgrade should appear as a separate drop down list because there can be a variety of different combination of upgrades eligible for selection (including selecting all of the upgrades listed).

    For example, after the Rhino unit is selected, the drop down lists in the Options column should read as follows:

    EFGHIJKL10: Storm Bolter
    EFGHIJKL11: Hunter-Killer Missile
    EFGHIJKL12: Dozer Blade
    EFGHIJKL13: Extra Armor

    With all four upgrades available for selection, the user can have the option to select either all, some, or none of the choices available in order to fully customize the selection. For example, let's say I wanted to take the Dozer Blade and Extra Armor upgrade but not the Storm Bolter and HK Missile. Having 4 drop down menus created dynamically would make this much easier to browse and select as opposed to listing every single available upgrade.

    Another example of this would be using the HQ FOS unit named Varro Tigurius. His available options/upgrades should read as follows

    EFGHIJKL10:
    Smite
    Force Dome
    Machine Curse
    The Avenger
    Quickening
    Null Zone
    Might of the Ancients
    The Gate of Infinity
    Vortex of Doom

    EFGHIJKL11:
    Smite
    Force Dome
    Machine Curse
    The Avenger
    Quickening
    Null Zone
    Might of the Ancients
    The Gate of Infinity
    Vortex of Doom

    Even though both columns are the same, in this given example, the user has the option to pick between 2 separate lists of powers. Therefore 2 drop down list choices are required in order to dynamically select 2 different powers from the given lists.

  6. #6
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,608

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    Okay, I think I understand better....

    But you will need to be more consistent with the formatting of your lookup tables in AD onward. For example for the Varro Tigrius table, move the second column over to the right by one, so that every other column has the text to return.

    Then name each range consistently starting from the the name in Column AD to the bottom right cell of the last column in the table. Note for multi-word tables like Varro Tigrius, you cannot have spaces... so even though cell AD2 has "Varro Tigrius", you must name the range as "VarroTigrius".

    Then for data validation formula for E9 use:

    =OFFSET(INDIRECT(SUBSTITUTE($A$3," ","")),0,1,COUNTA(INDEX(INDIRECT(SUBSTITUTE($A$3," ","")),0,2)-1),1)

    in E10, slightly change to:

    =OFFSET(INDIRECT(SUBSTITUTE($A$3," ","")),0,3,COUNTA(INDEX(INDIRECT(SUBSTITUTE($A$3," ","")),0,4)-1),1)

    The E11:

    =OFFSET(INDIRECT(SUBSTITUTE($A$3," ","")),0,5,COUNTA(INDEX(INDIRECT(SUBSTITUTE($A$3," ","")),0,6)-1),1)

    and so on with same pattern.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  7. #7
    Registered User
    Join Date
    09-01-2011
    Location
    Blythe, AZ
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    Awesome! Now we're getting somewhere.

    There's only one minor hiccup. I've adjusted all of the named ranges to include underscores so the lists are populating correctly, however, they are only displaying the first item in the column of the corresponding unit. In one of my previous posts, I believe I had an example of one unit that was supposed to have a list of 6-8 items to be placed in a drop down list yet only the top entry is populated in the list.

  8. #8
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,608

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    It worked for me using my method. See attached sample. I have Varro Tigrius in A3 and named the range Varro_Tigrius

    If you use underscores, the the SUBSTITUTE functions have to account for that, e.g. SUBSTITUTE($A$3," ","_")

    I only did the validation in E9 and E10
    Attached Files Attached Files
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  9. #9
    Registered User
    Join Date
    09-01-2011
    Location
    Blythe, AZ
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    Hmm, it's the weirdest thing. When I went in and entered all of the underscore changes, the drop down list worked perfectly for every cell. Then after I closed and reopened it, the changes were still there but it the drop down list have reverted back down to a single item. Funny thing, when I downloaded your spreadsheet, it did the exact same thing.

    I've attached an updated spreadsheet. All of the unit names have underscores now and are linked to the data on the right. Everything should work (in theory) but if there's anything I'm missing I'd greatly appreciate additional help.
    Attached Files Attached Files

  10. #10
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,608

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    I see what you mean.

    Try instead this simpler data validation formula in E9

    =INDEX(INDIRECT(SUBSTITUTE($A$3," ","_")),0,2)

    and in E10

    =INDEX(INDIRECT(SUBSTITUTE($A$3," ","_")),0,4)

    and so on
    Last edited by NBVC; 09-07-2011 at 01:11 PM.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  11. #11
    Registered User
    Join Date
    09-01-2011
    Location
    Blythe, AZ
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    Success! It works! This is awesome. Thank you so much.

    One minor thing, not that much of a big deal, but is it possible to take all of that data on the right side of the sheet and:

    1) Move it to a new worksheet
    or
    2) Hide it out of view
    Last edited by MavGunloc; 09-07-2011 at 01:32 PM.

  12. #12
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,608

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    Select all those columns and CUT (CTRL+X), then paste into a new sheet... the references should follow....
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  13. #13
    Registered User
    Join Date
    09-01-2011
    Location
    Blythe, AZ
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    Awesome! You are my hero.

    Another minor thing I forgot to mention in the heat of things. I was so concerned about the dynamic lists I forgot how to properly add 2 vlookup instances.

    Each of the options has a points lists attached to it. All I really want in the Vlookup to grab the numbers to the right of the options and place them in the points column. Since there may be two sets of options with differing points on each side, I'm curious as to how I would add them together in order to make them work and also have any #REF/#VALUE errors to remain invisible like I did for the first Points column cell Q3.

  14. #14
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,608

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    If I understand correctly, try:

    In R9:

    =IFERROR(VLOOKUP(E9,OFFSET(INDIRECT(SUBSTITUTE($A$3," ","_")),0,1,,2),2,0),"")

    in R10:

    =IFERROR(VLOOKUP(E9,OFFSET(INDIRECT(SUBSTITUTE($A$3," ","_")),0,3,,2),2,0),"")

    and so on.

    You can enter the formula once in R9 and copy down, then just change the Bold Red number in each formula by adding 2 as you go down.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  15. #15
    Registered User
    Join Date
    09-01-2011
    Location
    Blythe, AZ
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Using IF/VLOOKUP formulas INSIDE Data Validation

    Great! That worked perfectly for the 1st options column. My next question would be how would I get the two adjacent columns to add together should there be enough options to fill both columns.

    For example, the Vanguard_Veteran_Squad in the Fast_Attack FOS can have additional units in column E9 and Thunder Hammers in M9, each with their own separate point cost. I would need the points cell for that row to add up both values (if applicable).

+ 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.2.0