Bonjour
Code de user initialise
Private Sub UserForm_Initialize()
Dim j As Integer
'#Mise en place des colonnes de la LitsBox1
Me.ListBox1.ColumnCount = 4
Me.ListBox1.ColumnWidths = "50;100;200;200"
'# Combobox 3
With Me.ComboBox3
.ColumnCount = 2
.ColumnWidths = "-1;0"
End With
'''''''''''''''''''''''''''''''''''''''
' Set Clients = CreateObject("Scripting.Dictionary")
' Set Ws = Sheets("Cat et thème")
' With Ws
' For Each Cel In .Range("A2", .[A65000].End(xlUp))
' Clients(Cel.Value) = Cel.Value
' Next Cel
' End With
' Me.ComboBox1.List = Application.Transpose(Clients.keys)
combos
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Me.ComboBox1.SetFocus
'# Initialisation des objets (date et heure)
Me.TextBox1 = Date
Me.TextBox2.Value = Format(Time, "hh:mm")
Me.DTPicker1 = Date
' BtValList
If Sheets("passage").Range("A2") <> "" Then
Alim_ListBx1 'Alimatation de la ListBox
CdBValider.Visible = True
End If
End Sub
puis dans un nouveau module
Sub combos()
Dim c, combo, derligne, Plage, mondico, temp, Ws As Worksheet
Set Ws = Sheets("Cat et thème")
derligne = Ws.Range("A" & Rows.Count).End(xlUp).Row
Set Plage = Ws.Range(Ws.Cells(2, 1), Ws.Cells(derligne, 1))
Set mondico = CreateObject("Scripting.Dictionary")
For Each c In Plage
If c.Value <> "" Then mondico.Item(c.Value) = c
Next c
temp = mondico.ItemS
If mondico.Count > 0 Then
Call Tri(temp, LBound(temp), UBound(temp))
UserForm1.ComboBox1.List = temp
End If
temp = ""
End Sub
Sub Tri(a, gauc, droi)
Dim ref, g, d, temp
ref = a((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(g) < ref: g = g + 1: Loop
Do While ref < a(d): d = d - 1: Loop
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Tri(a, g, droi)
If gauc < d Then Call Tri(a, gauc, d)
End Sub