Sub Tri()
Application.ScreenUpdating = False
' Dernière ligne du tableau
DL = Range("C65500").End(xlUp).Row
Range("E8:F" & DL) = Range("B8:C" & DL).Value ' Copie matrice
' On remplace les DC=0 par DC=9999
For L = 9 To DL
If Cells(L, "F") = 0 Then Cells(L, "F") = 9999
Next L
' On trie le tableau sur DC croissant puis ID croissant
TriColC DL
' On remplace les DC=9999 par DC=0
For L = 9 To DL
If Cells(L, "F") = 9999 Then Cells(L, "F") = 0
Next L
End Sub
Sub TriColC(DL)
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range("F9:F" & DL) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range("E9:E" & DL) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Feuil1").Sort
.SetRange Range("E8:F" & DL)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub