1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Sub Trier()
Dim mylastrow As Range, Dcel As Range, x As Long
Set Dcel = Cells(Rows.Count, 1).End(xlUp)
For x = 1 To Dcel(1, 2).Row
Set mylastrow = Cells(x, 1).End(xlDown)
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range(Cells(x, 2), mylastrow(1, 2)), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Feuil1").Sort
.SetRange Range(Cells(x, 1), mylastrow(1, 3))
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
x = mylastrow.Row + 1
Next x
End Sub |