I'm bulting a small programm with vba Excel. My Comboxbox is filled from an excel sheet. I want to build some controls like "add / delete items" to add other items to my Combobox that why i need to know the row number for each item on my combobox. my code is capable of doing this but i still don't know how to sort the items alphabetically before adding them to the combobox ( see my code below) can you help please ? thanks in advance
Sub Fill_EightD_D1_CB1()
With EightD.EightD_D1_CB1
.ColumnCount = 2 ' 2 colonnes
.ColumnWidths = "-1;0" ' dont une de masquée
End With
Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("D1")
Dim LC As Long
Dim i As Long
LC = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
For i = 2 To LC
If ws.Cells(i, 1) <> "" Then
EightD.EightD_D1_CB1.AddItem ws.Cells(i, 1).Value
EightD.EightD_D1_CB1.List(EightD.EightD_D1_CB1.ListCount - 1, 1) = Mid(ws.Cells(i, 1).Address(False, False), 2, 1)
End If
Next i
'show always the first element
EightD.EightD_D1_CB1.ListIndex = 0
'Bold Text EightD_D1_CB1
EightD.EightD_D1_CB1.Font.Bold = True
End Sub