sorting/no duplicate scripting dictionary in Excel VBA

  • Thread starter Thread starter maximilianchu
  • Start date Start date
M

maximilianchu

How to sort the Combobox values from the scripting dicionary?

The following code works well when posting values in the combobox and
eliminating the dups:

Dim rSource As Range, cell As Range
Dim sVal As String

'Set rng = curWks.AutoFilter.Range
Set rSource = Worksheets("Master Interview Schedule").Range("A:A")
With ComboBox1
For Each cell In rSource.Cells
sVal = cell.Value
If Not dic.Exists(sVal) Then
dic.Add sVal, sVal
.AddItem sVal
End If
Next
End With
Set dic = Nothing

Is there a way to sort the values at the same time?
 
John Walkenbach shows how to sort elements of a collection. Maybe you could
modify it for your dictionary object.

http://j-walk.com/ss/excel/tips/tip47.htm

ps. rSource is gonna be a big range. You may want to limit it to something
smaller.

with worksheets("master interview schedule")
set rSource = .range("a1",.cells(.rows.count,"A").end(xlup))
end with
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top