Private Sub CommandButton2_Click()
'mettre la List sous forme de tableau
tableau = ListBox1.List
'Repeter dans le tableau la position
For n = LBound(tableau, 1) To UBound(tableau, 1)
'si la position n'est pas vide noter le numero
If tableau(n, 2) <> "" Then
num = tableau(n, 2)
'si la position est vide lui affecter le numero
Else
tableau(n, 2) = num
End If
Next n
'classer le tableau en fonction de position et reference
For n = LBound(tableau, 1) To UBound(tableau, 1)
For m = LBound(tableau, 1) To UBound(tableau, 1)
If tableau(n, 2) & tableau(n, 3) < tableau(m, 2) & tableau(m, 3) Then
temp0 = tableau(n, 0)
temp1 = tableau(n, 1)
temp2 = tableau(n, 2)
temp3 = tableau(n, 3)
temp4 = tableau(n, 4)
tableau(n, 0) = tableau(m, 0)
tableau(n, 1) = tableau(m, 1)
tableau(n, 2) = tableau(m, 2)
tableau(n, 3) = tableau(m, 3)
tableau(n, 4) = tableau(m, 4)
tableau(m, 0) = temp0
tableau(m, 1) = temp1
tableau(m, 2) = temp2
tableau(m, 3) = temp3
tableau(m, 4) = temp4
End If
Next m
Next n
' Oter les positions ajoutées pour faire le tri
num = tableau(0, 2)
For n = 1 To UBound(tableau, 1)
If tableau(n, 2) = num Then
tableau(n, 2) = ""
Else
num = tableau(n, 2)
End If
Next n
'Affecter le tableau a la List
ListBox1.RowSource = ""
ListBox1.List = tableau
End Sub