R
Rob W
Greetings,
I had an issue of how to populate my combo box with unique values only,
after some research I discovered collections and how they dont allow
duplicate values and I could simply skip the error to achieve the results I
wanted.
However how can I modify the code to sort the values in the collection
(Unique) in alphabetical order?
I've seen some complex looking loops based on the old bubble sort routines
that I wrote many many moons ago, but wondering what other peoples solutions
would be?
Any assistance would be appreciated.
Cheers
Rob
'Populate combo box with unique Diagnosis values
With comboDiagnosis
Dim Uniques As New Collection
Dim unsorted As Boolean
On Error Resume Next
For Each cell In wsData.Range("G2:G" &
lRowEnd).SpecialCells(xlCellTypeConstants, 2)
Uniques.Add cell.Value, CStr(cell.Value)
Next cell
For Each Item In Uniques
comboDiagnosis.AddItem Item
Next Item
End With
I had an issue of how to populate my combo box with unique values only,
after some research I discovered collections and how they dont allow
duplicate values and I could simply skip the error to achieve the results I
wanted.
However how can I modify the code to sort the values in the collection
(Unique) in alphabetical order?
I've seen some complex looking loops based on the old bubble sort routines
that I wrote many many moons ago, but wondering what other peoples solutions
would be?
Any assistance would be appreciated.
Cheers
Rob
'Populate combo box with unique Diagnosis values
With comboDiagnosis
Dim Uniques As New Collection
Dim unsorted As Boolean
On Error Resume Next
For Each cell In wsData.Range("G2:G" &
lRowEnd).SpecialCells(xlCellTypeConstants, 2)
Uniques.Add cell.Value, CStr(cell.Value)
Next cell
For Each Item In Uniques
comboDiagnosis.AddItem Item
Next Item
End With