M
Michel
Guest
bonjour
comment trier et virer les doublons dans une combobox en faisant au plus simple
merci
comment trier et virer les doublons dans une combobox en faisant au plus simple
merci
Dim typemachine As Collection
Dim c As Range
Dim i As Byte
Set typemachine = New Collection
On Error Resume Next
For Each c In Range('w2:w' & Range('w500').End(xlUp).Row)
typemachine.Add c.Text, c.Text
Next c
For i = 1 To typemachine.Count
ComboBox2.AddItem typemachine(i)
Next i
Private Sub UserForm_Initialize()
Dim Typemachine As Collection
Dim c As Range
Dim i As Integer
Set Typemachine = New Collection
With ThisWorkbook.Worksheets('NomDeTaFeuille')
On Error Resume Next
For Each c In .Range('w2:w' & .Range('w500').End(xlUp).Row)
Typemachine.Add CStr(c.Text), CStr(c.Text)
Next c
On Error GoTo 0
End With
For i = 1 To Typemachine.Count
ComboBox2.AddItem Typemachine(i)
Next i
End Sub
Dim Cel As Range
Dim x As Long
For Each Cel In Range('W2:W' & Range('W500').End(xlUp).Row)
If ComboBox2.ListCount > 0 Then
For x = 0 To ComboBox2.ListCount - 1
If Cel.Value = ComboBox2.List(x) Then GoTo suite
Next x
End If
ComboBox2.AddItem Cel.Value
suite:
Next Cel