View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Abhay Sanan Abhay Sanan is offline
external usenet poster
 
Posts: 4
Default adding into combo box and removing duplicates

i have a list in my spreadsheet which needs to be added to my combo box
list. The problem is that there are repeated number of these values. This is
the code I have written but it does not work as i need it to. Not all the
values have been added into the list. Also for every letter i type in the
combo box this function is called making it slow. If some1 could correct it,
it would be great. Thanks!

Private Sub ComboBox1_Change()
Dim i As Integer
Dim j As Integer
Dim count As Integer
Dim entry As String
Dim check As String

Range("C8",Range("C8").End(xlDown)).Select
count = Selection.Rows.count

Worksheets("Portfolio").Range("DR11")=count
For i = 8 To count
entry = Cells(i, 3).Value
ComboBox1.AddItem (entry)
Next i

For i = 8 To count
entry = Cells(i, 3).Value
For j = i + 1 To count
check = Cells(j, 3).Value
If entry = check Then
ComboBox1.RemoveItem (j)
End If
Next j
Next i
End Sub


It would be great too if some1 cud show me how to sort the list.