PDA

View Full Version : Solved: ComboBox (SOLVED)



Nicolaf
09-06-2011, 03:49 AM
Hi,

I have created a ComboBox in a Userform using code below:


Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "France"
.AddItem "Italy"
.AddItem "Spain"
.AddItem "Guatemala"
End With
End Sub

Instead of adding each item (ie. country names) can I put in code the reference to a country list in Excel? This way I would not have to add each single item but simply reference cells.

So if my country names were found in Sheet1 from A1 to A4 how would my code look?

Thanks!
:confused:

Aflatoon
09-06-2011, 04:00 AM
You may use the List property for example:


Private Sub UserForm_Initialize()
ComboBox1.List = Sheets("Sheet1").Range("A1:A4").Value2
End Sub

Nicolaf
09-06-2011, 04:41 AM
Thanks!

:hi: