Option Explicit
Sub Macro1()
Dim i As Long ' variable i définie
Range("A1:G1").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("Feuil1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Feuil1").AutoFilter.Sort.SortFields.Add Key:=Range _
("C1"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Feuil1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Selection.AutoFilter
For i = 2 To 65536
If Cells(i, 1) = "" Then Exit For
Cells(i, 1).ClearContents
If Cells(2, 1) = "" Then
Cells(2, 1) = 1
Else
Cells(i, 1) = Cells(i - 1, 1) + 1
End If
Next i
End Sub