Try this in your Userform Module:-
Userfom1 Contains:- ListBox1 and Combobox1
Option Explicit
Private Sub UserForm_Initialize()
Dim Rng As Range, Dn As Range, n As Long
Dim Dic As Object
Set Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
Set Dic = CreateObject("scripting.dictionary")
Dic.CompareMode = vbTextCompare
For Each Dn In Rng
Dic(Dn.Value) = Empty
Next Dn
With Me.ComboBox1
.List = Application.Transpose(Dic.keys)
.ListIndex = 0
End With
End Sub
Private Sub ComboBox1_Change()
Dim Rng As Range
Dim Dn As Range
Dim Ac As Integer
Dim c As Long
Dim J, I
Dim temp(1 To 11)
Dim n As Integer
Set Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
ReDim ray(1 To 11, 1 To Rng.Count)
For Each Dn In Rng
If Dn = ComboBox1 Or Dn.Row = 1 Then
c = c + 1
For Ac = 1 To 11
ray(Ac, c) = Dn(, Ac)
Next Ac
End If
Next Dn
ReDim Preserve ray(1 To 11, 1 To c)
For I = 2 To UBound(ray, 2)
For J = I To UBound(ray, 2)
If ray(2, J) < ray(2, I) Then
For n = 1 To 11
temp(n) = ray(n, I)
ray(n, I) = ray(n, J)
ray(n, J) = temp(n)
Next n
End If
Next J
Next I
With ListBox1
.ColumnCount = 11
.ColumnWidths = "100;70;110;100;50;70;100;80;100;100;110"
.List = Application.Transpose(ray)
End With
End Sub
Regards Mick
Bookmarks