How to sort Dictionary Object alphabetically

bradyboyy88

Well-known Member
Joined
Feb 25, 2015
Messages
562
I have a listbox with unique values using a scripting.dictionary object but all the items are out of order. Is there a way to sort alphabetically using the scripting.dictionary object?

Code:
Private Sub ActivateFILTER_BROWSE(FilterButt*******ed_BROWSE As MSForms.Label, Field As String)
    Dim FilterList As Scripting.Dictionary, item, tmp As String
    Set FilterList = CreateObject("scripting.dictionary")
    FilterBoxListbox_BROWSE.Clear
    
    ActiveRecordset.MoveFirst
    Do While Not ActiveRecordset.EOF
            tmp = Trim(ActiveRecordset.Fields(Field).Value)
            If Len(tmp) > 0 Then FilterList(tmp) = FilterList(tmp) + 1
        ActiveRecordset.MoveNext
    Loop
    
    FilterBoxListbox_BROWSE.AddItem "Select All"
    For Each item In FilterList.Keys
        FilterBoxListbox_BROWSE.AddItem item
        
    Next item
    
    Set FilterList = Nothing
    
    If FilterButt*******ed_BROWSE.Left + FilterBoxFrame_BROWSE.Width > BrowseFrame.Width Then
        FilterBoxFrame_BROWSE.Top = FilterButt*******ed_BROWSE.Top
        FilterBoxFrame_BROWSE.Left = FilterButt*******ed_BROWSE.Left - FilterBoxFrame_BROWSE.Width
    Else
        FilterBoxFrame_BROWSE.Top = FilterButt*******ed_BROWSE.Top
        FilterBoxFrame_BROWSE.Left = FilterButt*******ed_BROWSE.Left
    End If
    EnableEvents = True
    Call HighlightCollectionItems(LastCollecti*******ed_BROWSE)
    EnableEvents = False
    FilterBoxFrame_BROWSE.ZOrder (0)
    FilterBoxFrame_BROWSE.Visible = True
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,216,482
Messages
6,130,928
Members
449,607
Latest member
babylegs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top