Excel button to choose
I want to know if it is possible with buttons or list or with some formula. For example I have a list with the name of the countries (Portugal, Spain, Brazil) and I want the other list to only show me the capitals of these countries.
Example:
I choose in one list or another any Spain I want in the other list shows me the most important places.
Espanha --> Madrid
Barcelona
Sevilha
And that you can select one of them
0
1 answers
Good
Take a look at this code, see if it works:
Private Sub UserForm_Initialize()
ComboBox1.AddItem "Grains"
ComboBox1.AddItem "Fruits"
ComboBox1.AddItem "Dairy"
End Sub
Private Sub ComboBox1_Change()
Application.EnableEvents = False
ComboBox2.Clear
Application.EnableEvents = True
Select Case ComboBox1.Value
Case "Grains"
ComboBox2.AddItem "Cereals"
ComboBox2.AddItem "Breads"
ComboBox2.AddItem "Pastsa"
Case "Fruits"
ComboBox2.AddItem "Apples"
ComboBox2.AddItem "Oranges"
ComboBox2.AddItem "Pears"
Case "Dairy"
ComboBox2.AddItem "Cheese"
ComboBox2.AddItem "Milk"
ComboBox2.AddItem "Yogurt"
End Select
End Sub
2
Author: jsantos1991, 2014-07-14 13:04:09