Combobox in userform

A

Alvin Hansen

Just help ao I con start on this
How do i get data from a sheet in to the combobox
combobox is on userform

Alvin
 
J

JulieD

Hi Alvin

something along the lines of
Private Sub UserForm_Initialize()
Dim myrange As Range

Set myrange = Sheets("Sheet4").Range("A1:A10")

For Each c In myrange
ComboBox1.AddItem c.Value
Next
End Sub

Hope this helps
Cheers
JulieD
 
N

Newbie

Name your array in the sheet then set your 'Rowsource' property available in
the combobox properties screen e.g. "=listname"
 
J

JulieD

Hi Alvin

thanks for the feedback ..."Newbie's" suggestion is an alternative method
you might consider - but i've never done it that way so i'm not sure of the
Pros and Cons

Cheers
JulieD
 
H

Harald Staff

Hi Julie

That's the old discussion of databound vs unbound controls, a question of
personal style and strong beliefs <g>. I always use your way of doing
things, "unnecessary" code instead of databinding properties.

Best wishes Harald
 
T

Tom Ogilvy

Another way would be

Private Sub UserForm_Initialize()
ComboBox1.List = Sheets("Sheet4"). _
Range("A1:A10").Value
End Sub
 
Top