Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Drop-down list Question

Posted on 2012-04-02
10
Medium Priority
?
277 Views
Last Modified: 2012-04-02
On a separate worksheet I have a vlookup table that has columns like these:

CountryID     CountryName
---------     -----------
   1          United States
   2          Canada
   3          China
etc...

Open in new window


I've seen examples that show how to display the drop down and see the country names themselves, but I would like to know how to insert the CountryID instead of the CountryName in the cell. So when a user clicks the dropdown on the cell, they will see the country names listed, but when they select "United States" the CountryID of "1" is added to the column.

Is this possible? Are there any exampels of this anywhere?
0
Comment
Question by:greddin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 42

Expert Comment

by:dlmille
ID: 37798163
See attached example, using MS Forms Drop Down.  if you right click the drop down, you can format the control, set a range equal to what's displayed, and also a cell link.  The cell link will get a number from 1-X in order of the drop down.

Dave
exampleDropDown-r1.xls
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 37798168
Use the Combo1.ItemData(index) value.

For example Range("A1").Value = Combo1.Itemdata(2)
0
 
LVL 42

Expert Comment

by:dlmille
ID: 37798178
In the attached, using a data validation list below the drop down example, you can select any country and have that country's ID displayed using an INDEX/MATCH function.

Cheers,

Dave
exampleDropDown-r2.xls
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 17

Expert Comment

by:andrewssd3
ID: 37798194
Here is a simple example using an ActiveX ComboBox.  The key things are, look at the properties of the combobox - make ColumnCount = 2, then ColumnWidths 0; to make the first column hidden.  Keep BoundColumn as 1 - that says use the first column as the result.  ListFillRange is set to 'Countries', a named range that includes the id and name columns for the countries, and finally LinkedCell is set to E1 to say put the result in E1 (ie this is where the bound column value will go.countries.xlsx

Hope this helps

Stuart
0
 

Author Comment

by:greddin
ID: 37798203
To dlmille, when using a form like this how would I use this form control down the entire column. On my first worksheet when I'm selecting the country, there will be a long list of rows where I have to select the country. Your example is almost what I envision, but is there a way to do this with a vlookup function?
0
 
LVL 42

Accepted Solution

by:
dlmille earned 2000 total points
ID: 37798210
What type of drop down do you want to use?  A DV list or a Drop down?  See attached last example, and I can expand from there.

A DV list is easy to propagate down a column.  A control takes up memory and can get messy.

Dave
exampleDropDown-r3.xls
0
 
LVL 42

Expert Comment

by:dlmille
ID: 37798219
See this last example, where you have a larger column of countries to select.  Its easy enough then to use the lookups to find the country ID.

Dave
exampleDropDown-r4.xls
0
 
LVL 17

Expert Comment

by:andrewssd3
ID: 37798220
Looks like everyone was busy while I was typing my answer :)  If you want a whole column, the best options would be Dave's data validation solution, as this is easy to apply to multiple cellls - you could addd the controls, but that would require VBA and be quite clumsy and difficult to extend
0
 

Author Comment

by:greddin
ID: 37798249
Thanks Dave for the newer example, looks like the data validation list is what I wanted. This is perfect. Thanks for showing me an example.
0
 

Author Closing Comment

by:greddin
ID: 37798254
Thanks again!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question