
Private Sub UserForm_Activate()
[G2:G100].RemoveDuplicates Columns:=Array(1), Header:=xlNo
ComboBox1.RowSource = "G2:G100"
End Sub |
Private Sub UserForm_Activate()
Dim Arr As Collection
Dim Uriga As Long, i As Long
Set Arr = New Collection
Uriga = Worksheets("Foglio1").Cells(Rows.Count, "G").End(xlUp).Row
On Error Resume Next
For i = 2 To Uriga
With Worksheets("Foglio1").Cells(i, "G")
Arr.Add .Value, .Text
If Err.Number = 0 Then
Me.ComboBox1.AddItem .Text
Else
Err.Clear
End If
End With
Next i
Set Arr = Nothing
End Sub
|
Function NoDuple_Dic(arr()) As Variant()
'by "nick r"
Dim Dic As Object
Dim t
'passando una matrice, restituisce un vettore
'con i soli valori non duplicati
'utilizza un dictionary
Set Dic = CreateObject("Scripting.Dictionary")
For Each t In arr
If Dic.Exists(t) = False Then Dic.Add t, 0
Next
NoDuple_Dic = Dic.keys
End Function |
Dim UltimaRiga
UltimaRiga = ws.Range("E3").End(Microsoft.Office.Interop.Excel.XlDirection.xlDown).Row
For index As Integer = 3 To UltimaRiga
ComboBox1.Items.Add(ws.Cells(index, 8).value)
ComboBox1.Items.Add(ws.Cells(index, 8).value)
ComboBox2.Items.Add(ws.Cells(index, 5).value)
ComboBox3.Items.Add(ws.Cells(index, 6).value)
ComboBox4.Items.Add(ws.Cells(index, 7).value)
ComboBox5.Items.Add(ws.Cells(index, 9).value)
ComboBox1.Sorted = True
ComboBox2.Sorted = True
ComboBox3.Sorted = True
ComboBox4.Sorted = True
ComboBox5.Sorted = True
Next index
|
Dim i As Long
For i = Combo1.ListCount - 1 to 1 Step -1
If Combo1.List(i) = Combo1.List(i - 1) Then ' add UCase$ or LCase$ if you care about case
Combo1.RemoveItem i
End If
Next i |
Option Explicit
Sub test()
Dim v As Variant, r As Range, arr() As Variant, i As Integer
Dim f As Variant
Set r = [a1:a10]
ReDim arr(r.Count)
For Each v In r
arr(i) = v
i = i + 1
Next
f = NoDuple_Dic(arr)
For Each v In f
Debug.Print v
Next
End Sub
Function NoDuple_Dic(arr()) As Variant()
'by "nick r"
Dim Dic As Object
Dim t
'passando una matrice, restituisce un vettore
'con i soli valori non duplicati
'utilizza un dictionary
Set Dic = CreateObject("Scripting.Dictionary")
For Each t In arr
If Dic.Exists(t) = False Then Dic.Add t, 0
Next
NoDuple_Dic = Dic.keys
End Function |
