Av8tordude
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 1,074
- Office Version
- 2019
- Platform
- Windows
I have this code that add unique list to my combo box. I would like to know how I can add three items that will show in the first three items in the combo box list
i.e.
Standard 3 item list that will show no matter what
mary
Tom
John
And then the list the code includes below the standard list
i.e.
Standard 3 item list that will show no matter what
mary
Tom
John
And then the list the code includes below the standard list
VBA Code:
Private Sub UpdateList()
Dim Dic As Object: Set Dic = CreateObject("Scripting.Dictionary")
Dim rCell As Range, x, y, z
cbName.Clear
x = Wks.Cells(Rows.Count, "A").End(xlUp).Row
If x > 6 Then
For Each rCell In Wks.Range("A7:A" & x)
If Not Dic.Exists(rCell.Value) Then
Dic.Add rCell.Value, Nothing
End If
Next rCell
cbName.List = Dic.Keys
With cbName
For x = LBound(.List) To UBound(.List)
For y = x To UBound(.List)
If .List(y, 0) < .List(x, 0) Then
z = .List(y, 0)
.List(y, 0) = .List(x, 0)
.List(x, 0) = z
End If
Next y
Next x
End With
End If
End Sub