Excel button to choose

0

I want to know if it's possible with buttons or list or with some formula. For example I have a list with names of countries (Portugal, Spain, Brazil) and I want the other list to show me the capitals of these countries.

Example:

I choose in a list or some other way any Spain I want in the other list shows me the most important places.

 Espanha     -->    Madrid
                    Barcelona
                    Sevilha

And you can select one of them

    
asked by anonymous 14.07.2014 / 13:53

1 answer

2

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

link: link

    
14.07.2014 / 14:30