1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| Private Sub UserForm_Initialize()
Set f = Sheets("BD")
Me.ListBox1.List = f.Range("A2:D" & f.[A65000].End(xlUp).Row).Value
bd = f.Range("A2:D" & f.[A65000].End(xlUp).Row).Value ' version trié
Tri bd, LBound(bd), UBound(bd), 4
ListBox1.List = bd
'Supprimer les doublons dans une listbox
Dim i As Long, j As Long
With ListBox1
For i = 0 To .ListCount - 1
For j = .ListCount - 1 To (i + 1) Step -1
If .List(j) = .List(i) Then
.RemoveItem j
End If
Next
Next
End With
'format colonne 2
Dim x As Integer
With ListBox1
For x = 0 To ListBox1.ListCount - 1
.List(x, 2) = Format(.List(x, 2), "000")
Next x
End With
End Sub
Sub Tri(a, gauc, droi, colTri) ' Quick sort
ref = a((gauc + droi) \ 2, colTri)
g = gauc: d = droi
Do
Do While a(g, colTri) < ref: g = g + 1: Loop
Do While ref < a(d, colTri): d = d - 1: Loop
If g <= d Then
For c = LBound(a, 2) To UBound(a, 2)
temp = a(g, c): a(g, c) = a(d, c): a(d, c) = temp
Next
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Tri a, g, droi, colTri
If gauc < d Then Tri a, gauc, d, colTri
End Sub |
Partager