|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 it. |
|
#2
|
||||
|
||||
|
It's a bit awkward doing it that way. You could do it from a database easier.
However you decide, you need to do an sql statement. Code:
sql = "select distinct field1, field2 from table 1" You can set up your spreadsheet to act as a database but it's not recommended. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > adding into combo box and removing duplicates |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|