ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sorting/no duplicate scripting dictionary in Excel VBA (https://www.excelbanter.com/excel-programming/375768-sorting-no-duplicate-scripting-dictionary-excel-vba.html)

[email protected]

sorting/no duplicate scripting dictionary in Excel VBA
 
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?


Dave Peterson

sorting/no duplicate scripting dictionary in Excel VBA
 
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



wrote:

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?


--

Dave Peterson


All times are GMT +1. The time now is 06:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com