Bonjour,
Un essai ...
Sub gestnoexamen()
Dim Dl As Integer
Dl = Cells(Rows.Count, "A").End(xlUp).Row '' << trouve la dernière ligne
Application.ScreenUpdating = False
Range("T17").FormulaR1C1 = "=COUNTIF(R17C6:RC[-14],RC[-14])"
Range("T17").AutoFill Destination:=Range("T17:T" & Dl)
ActiveWorkbook.Worksheets("g").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("g").AutoFilter.Sort.SortFields.Add2 Key:=Range( _
"T16"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("g").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("B17").FormulaR1C1 = "1"
Range("B18").FormulaR1C1 = "2"
Range("B17:B18").AutoFill Destination:=Range("B17:B" & Dl)
Range("T9").Select
Application.ScreenUpdating = True
End Sub
ric