zoltix
asked on
VBA: How to fill in a comboxbox from excell sheet?
I must do a little program in excell vba but I must fill in a combox from excell sheet with distinct value. Could you help me.
EX:
LLII
PASE
PASE
QSDF
QSDF
GDQD
wxcv
wxcv
wxcv
wxcv
In my combobox I neeed only LLII,PASE,QSDF,GDQD,wxcv(i t s important have just one)?
Thank
EX:
LLII
PASE
PASE
QSDF
QSDF
GDQD
wxcv
wxcv
wxcv
wxcv
In my combobox I neeed only LLII,PASE,QSDF,GDQD,wxcv(i
Thank
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sub FillCombo()
Dim sht As Worksheet
Dim lRow As Long
Dim sValue As String
Set sht = Sheets(2) 'data sheet
lRow = 1 'startrow
On Error Resume Next
With ComboBox1
.Clear
.Style = fmStyleDropDownList
Do
sValue = sht.Cells(lRow, 1).Value
If Len(sValue) = 0 Then Exit Do 'exit if no value
.Text = sValue
If Err.Number <> 0 Then 'not added yet
.AddItem sValue
End If
Err.Clear
lRow = lRow + 1
Loop
End With
End Sub
D'Mzzl!
RoverM