ComboBox: Display value from a range defined by name
Solved
xaveria
-
xaveria -
xaveria -
Hello,
I have a form located in one sheet of my Excel workbook (Sheet1), and all the choice lists I want to have are in another sheet (Sheet3). All these lists have defined names in my workbook.
In my form, I want to have a dropdown list of choices, so I used the ComboBox, but I can't seem to display the desired values when I click the arrow of the list in the form. I'm not sure which event to choose to achieve this. The list remains empty.
Here is what is currently in the code:
Private Sub cbxSecteur_change()
Dim ChoixSecteurs As String
ChoixSecteurs = Sheet3.Range("Secteurs").Value
CbxSecteur.Rowsource = ChoixSecteurs
End Sub
Configuration: Windows 7 / Internet Explorer 8.0
I have a form located in one sheet of my Excel workbook (Sheet1), and all the choice lists I want to have are in another sheet (Sheet3). All these lists have defined names in my workbook.
In my form, I want to have a dropdown list of choices, so I used the ComboBox, but I can't seem to display the desired values when I click the arrow of the list in the form. I'm not sure which event to choose to achieve this. The list remains empty.
Here is what is currently in the code:
Private Sub cbxSecteur_change()
Dim ChoixSecteurs As String
ChoixSecteurs = Sheet3.Range("Secteurs").Value
CbxSecteur.Rowsource = ChoixSecteurs
End Sub
Configuration: Windows 7 / Internet Explorer 8.0
'VBA Userform
'or
'or
'Directly in the RowSource property of ComboBox1: Sectors
A+
Private Sub UserForm_Activate()
CbxSecteur.Clear
'filling by address of the range
CbxSecteur.RowSource = Worksheets("feuil3").Range("Secteurs").Address
End Sub
CbxSecteur.RowSource = Worksheets("feuil3").Range("Secteurs").Address
It doesn't work, that's why I hadn't included it, but by using an intermediate variable it works, funny how that is!!!
Catch you later!
I forgot the name of the sheet:
ex:
Private Sub UserForm_Activate()
x = "sheet3!" & Worksheets("sheet3").Range("list2").Address
ComboBox1.RowSource = x
End Sub