-
Populate and Sort a ComboBox with visible unique values from an Excel table
Good Morning,
I'm new here. My name is Edoardo.
I'm using this code for populing a ComboBox with visible unique values from an Excel table filtered:
Private Sub UserForm_Initialize()
Dim Lrow As Long, test As New Collection
Dim Value As Variant, temp As Range
Dim i As Single
On Error Resume Next
Set temp = Worksheets("Sheet1").ListObjects("Table1").ListColumns(1).Range
For i = 2 To temp.Cells.Rows.Count
If Len(temp.Cells(i)) > 0 And Not temp.Cells(i).EntireRow.Hidden Then
test.Add temp.Cells(i), CStr(temp.Cells(i))
End If
Next i
UserForm1.ComboBox1 = Clear
For Each Value In test
UserForm1.ComboBox1.AddItem Value
Next Value
Set test = Nothing
End Sub
That code works but I would like the values displayed in the ComboBox to be also sorted progressively. Can someone help me?
My english is not perfect because I'm italian, I apologize.
Thanks a lot to anyone who will help me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules