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 27 28 29 30 31 32 33 34 35 36 37 38
| Sub TriEtSuppression()
Dim Plage As Range
Application.ScreenUpdating = False
With Feuil1
' pour chaque ligne
For i = 2 To .UsedRange.Rows.Count
' de la colonne B jusqu'à la dernière colonne
Set Plage = .Range(.Cells(i, 2), .Cells(i, .UsedRange.Columns.Count))
With .Sort
With .SortFields
' suppression du tri existant (s'il y en a un)
.Clear
' ajout de la plage de tri (ascendant sur les valeurs)
.Add Key:=Plage, SortOn:=xlSortOnValues, Order:=xlAscending
End With
' application du tri
.SetRange Plage
.Header = xlGuess
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
' ligne suivante
Next i
' suppression des cellules vides après avoir tout trié
.UsedRange.SpecialCells(xlCellTypeBlanks).Delete shift:=xlToLeft
End With
Application.ScreenUpdating = True
End Sub |
Partager