Hi, after sorting information that I show in a listbox I would like to
highlight the first item showing up at top of the listbox(right now I
get by default a dotted line under the first item)
Thank's ahead for any hint!
My code:
Dim NoDupes As New Collection
Dim i As Integer, j As Integer
Dim Swap1, Swap2, Item
Sub slist()
i = 1
Set NoDupes = New Collection
For Each ws In Worksheets
NoDupes.Add (Worksheets(i).Name)
i = i + 1
Next ws
' Sort the collection
For i = 1 To NoDupes.Count - 1
For j = i + 1 To NoDupes.Count
If NoDupes(i) > NoDupes(j) Then
Swap1 = NoDupes(i)
Swap2 = NoDupes(j)
NoDupes.Add Swap1, before:=j
NoDupes.Add Swap2, before:=i
NoDupes.Remove i + 1
NoDupes.Remove j + 1
End If
Next j
Next i
' Add the sorted items to a ListBox
Userform1.ListBox1.Clear
For Each Item In NoDupes
Userform1.ListBox1.AddItem Item
Next Item
Userform1.Show
Set NoDupes = New Collection
End Sub
Bookmarks