1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Sub lanceLeTri(debut As Integer, fin As Integer)
Dim ligneDebut As Integer, ligneFin As Integer
ligneDebut = Selection.Row
ligneFin = Selection.Rows.Count + Selection.Row - 1
ActiveSheet.Sort.SortFields.Clear
Debug.Print debut, fin
'boucle sur chaque colonne a trier
Dim i As Integer
For i = debut To fin
Debug.Print (i)
ActiveSheet.Sort.SortFields.Add2 Key:=Range(Cells(ligneDebut, i), Cells(ligneFin, i)), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
Next i
With ActiveSheet.Sort
.SetRange Range(Cells(debut, Selection.Column), Cells(fin, Selection.Column + Selection.Columns.Count - 1))
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub |
Partager