Try
Option Explicit
Private Sub UserForm_Initialize()
Dim rHeaders As Range
Dim rcl As Range
Dim cColl As Collection
Dim vItm As Variant
Dim i As Long, j As Long
Dim vTemp As Variant
Set cColl = New Collection
'fill the collection
Set rHeaders = Range(Cells(1, 1), Cells(1, Columns.Count).End(xlToLeft))
For Each rcl In rHeaders
cColl.Add rcl.Value, rcl.Value
Next rcl
'Two loops to bubble sort
For i = 1 To cColl.Count - 1
For j = i + 1 To cColl.Count
If cColl(i) > cColl(j) Then
'store the lesser item
vTemp = cColl(j)
'remove the lesser item
cColl.Remove j
're-add the lesser item before the
'greater Item
cColl.Add vTemp, vTemp, i
End If
Next j
Next i
'fill combo
For Each vItm In cColl
Me.ComboBox1.AddItem vItm
Next vItm
End Sub
Bookmarks