1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| 'Adresse de ta sélection
adress = Selection.Address(0, 0)
'Décomposition et recomposition
deb = Left(Selection.Address(0, 0), InStr(1, Selection.Address(0, 0), ":") - 1)
fin = Mid(Selection.Address(0, 0), InStr(1, Selection.Address(0, 0), ":") + 1, Len(Selection.Address(0, 0)))
debcol = Left(deb, 1)
deblig = Right(deb, 1)
fincol = Left(fin, 1)
finlig = Right(fin, 1)
sel1 = deb & ":" & debcol & finlig
sel2 = fincol & deblig & ":" & fin
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range(sel1), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range(sel2), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Feuil1").Sort
.SetRange Range(adress)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With |
Partager