
Sub CreaElencoUnivoco()
Dim CL As Range, Intervallo As Range, Elenco As New Collection
Dim Valori As Variant
Worksheets("Foglio1").Select
Set Intervallo = Range("A1", Range("A1").End(xlDown))
On Error Resume Next
For Each CL In Intervallo
Elenco.Add CL.Value, CStr(CL.Value)
Next
On Error GoTo 0
With Worksheets("Foglio1")
.ComboBox1.Clear
For Each Valori In Elenco
.ComboBox1.AddItem Valori
Next
End With
End Sub
|
Option Explicit
Sub fill_combo_with_uniques()
Dim v As Variant
Dim dict As Object, rng As Variant, i As Long, last_row As Long
Set dict = CreateObject("Scripting.Dictionary")
last_row = Cells(Rows.Count, 1).End(xlUp).Row
rng = Range("A1:A" & last_row)
For i = 1 To UBound(rng, 1)
dict(rng(i, 1)) = 0
Next i
v = Application.Transpose(dict.keys)
Load UserForm1
With UserForm1
.ComboBox1.List = v
.Show
End With
End Sub
|
