I'm having an issue filtering and sorting a scripting dictionary. The macro I am using creates a dictionary and displays it on a userform. However, there repeated values in the dictionary, and the values are not in alphabetical order. Is it possible to do put the values in alphabetical order and remove the duplicates? Any help is appreciated.
Private dic As Object
Private Sub UserForm_Initialize()
Dim a, i As Long, w()
With Sheets("Holdings For Export")
a = .Range("D4103", .Range("d" & Rows.Count).End(xlUp)).Resize(, 25).Value
End With
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = 1
For i = 2 To UBound(a, 1)
If Not dic.exists(a(i, 1)) Then dic.Item(a(i, 1)) = Empty
If IsEmpty(dic.Item(a(i, 1))) Then
ReDim w(0)
Else
w = dic.Item(a(i, 1))
ReDim Preserve w(UBound(w) + 1)
End If
w(UBound(w)) = a(i, 25)
dic.Item(a(i, 1)) = w
Next
Me.ManagerSellEntity.list = dic.keys
End Sub
Private Sub ManagerSellEntity_Click()
Me.ManagerSellManager.list = dic(Me.ManagerSellEntity.Value)
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Set dic = Nothing
End Sub
Bookmarks