ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fill combobox from specified range (https://www.excelbanter.com/excel-programming/302470-fill-combobox-specified-range.html)

anb001[_5_]

Fill combobox from specified range
 
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

--
Message posted from http://www.ExcelForum.com


gitcypher[_22_]

Fill combobox from specified range
 
A7 : A100

--
Message posted from http://www.ExcelForum.com


anb001[_6_]

Fill combobox from specified range
 
A small error. Should be range A6:A20

--
Message posted from http://www.ExcelForum.com


gitcypher[_23_]

Fill combobox from specified range
 
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

--
Message posted from http://www.ExcelForum.com


anb001[_7_]

Fill combobox from specified range
 
Worked like a charm.
Thnks

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 04:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com