Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
What I have:
Sheet 1 has a list of tank_id's (no duplicates) called "Details" (Columns are Tank_id, Tank_Name, Nation, Turret, TArmor_front, TArmor_rear, TView_range..).
Sheet 2 has a list of Turrets and the specifications called "Turrets". (Columns are Tank_id, Turret_id, Turret_Name, Armor_front, Armor_rear, View_range.)
I have created a table of the turrets called tblTurrets and named a range of all the turrets called allTurrets. I have named the Tank_id range as sTank_id_turrets and I have named the Turret_name range as sTurrets
there are 633 Tanks and 2000+ Turrets .

What I hope to accomplish:
I want a data validation lookup(DV) in $D$3 (the Turrets column) of the Details sheet to reference the tank_id in $A$3, of the Details sheet, and then compare it to the tank_id in the Turrets sheet. There might be up to 4 matches. Then populate the DV with the turrets names. Then when the Turret name is selected in the DV, to populate the cells to the right of it.

Another problem is there are also Radios, Suspensions, Engines and Guns sheets to populate the "Details" sheet DV's with.

1. What am I missing to load a complete list in order?
2. Is there a way to load the last value in the list by default?
3. How do I populate the cells to the right of the DV?

Any help with this will be appreciated.

What I have tried:

=INDEX(sTurrets;MATCH(A3;sTank_id_turret;0)) - works but doesnt get all the matches, only first one.

=VLOOKUP(A3;tblTurret;sTurrets;FALSE) - named range not found

=VLOOKUP(A3;allTurrets;sTurrets;FALSE) - currently evaluates to an error

=VLOOKUP(A3;sTank_id_turret;sTurrets;FALSE)- currently evaluates to an error

=OFFSET(sTurrets;MATCH($A$3; sTank_id_turret;0);0;COUNTIF(sTank_id_turret;$A$3);1) -
gets the right amount of matches, but not the first correct one. ie if the turrets names for tank_id 14913 were 't34 mod, Cruiser Mk1, Cz03 LTvz35, Leopard Prototype A1 and Leopard Prototype A2. This formula omits t34 mod and then added in Porsche T169, which is for tank_14914.

I have used in the formula1 of the DV:

'Turrets
   With Sheet1.Range("M3").Validation
       .Delete
       .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
           Operator:=xlBetween, Formula1:="=OFFSET(sTurrets;MATCH($A$3; sTank_id_turret;0);0;COUNTIF(sTank_id_turret;$A$3);1)"
       .IgnoreBlank = True
       .InCellDropdown = True
       .InputTitle = ""
       .ErrorTitle = ""
       .InputMessage = ""
       .ErrorMessage = ""
       .ShowInput = True
       .ShowError = True
   End With



Any help with this will be appreciated.
Posted
Updated 3-Mar-18 5:43am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900