Fill combobox from specified range

  • Thread starter Thread starter anb001
  • Start date Start date
A

anb001

I have a userform (userform1), with a combobox (combobox1) on it. When
start the userform from a sheet, the combobox should be filled with dat
from range A&:A200 in the same sheet. No dublicates should be added.

I have tried with the '.....userform1_initialize()', but nothing seem
to happen.

Can somebody give me the correct code.
Thnks
 
Private Sub UserForm_Initialize()


Dim num As Integer
Dim CellText
Dim Search

num = 6

Do
CellText = Range("A" & num).Value
Set Search = Range("A5:A" & num - 1).Find(CellText
LookIn:=xlValues)
'searches to see whether the text has shown up prior to curren
position
'if it's not found, it returns 'Nothing'
If Search Is Nothing Then
ComboBox1.AddItem CellText
End If
num = num + 1
Loop Until num = 200 ' Range("a" & num).Value = "" <<Use if you wan
it to go until the cell is blank




End Sub


-Gitcyphe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top