I'm new to VBA and I have some problems with how to do everything automatically. I have an active sheet for analysis and 10 sheets with data. Due to the type of analysis, I would like to use comboboxes to select data for analysis.
I would like to:
- To use combobox1 on activesheet to select sheet from where I read the data.
- To use combobox2 where is a list of names from the first column from the sheet selected in combobox1.
Example: Sheets 2-10 are names of countries, Column 1 are cities in those countries with data related with each city. So in combobox1 I select UK =sheet(4) , and then in combobox2 London= cell A40. Then i calculate B40 x C40 /F40...
I started like:
Public Sub Worksheet_Activate()
Dim x As Integer
totalcountries = Sheets.Count
For x = 2 To totalcountries
Me.Combobox1.AddItem Sheets(x).Name
Next x
End Sub
And:
Sub selectcity()
Sheets(1).combobox2.List = Sheets(4).Range("A2:A56").Value
End Sub
I don't know how to connect it. Thank you.