Bonjour,
De haut en bas et de gauche à droite, du plus petit au plus grand sur les nombres situés à gauche du tiret. Résultat sur la feuille "Feuil2" :
Sub Test()
Dim Plage As Range
Dim Cel As Range
Dim Tbl() As String
Dim I As Long
Dim J As Long
Dim K As Long
'défini la plage sur la feuille "Feuil1"
Set Plage = DefPlage(Worksheets("Feuil1"))
'dimensionne le tableau au nombre de cellules
ReDim Tbl(1 To Plage.Rows.Count * Plage.Columns.Count)
'rempli le tableau
For Each Cel In Plage
I = I + 1: Tbl(I) = Cel.Value
Next Cel
'effectue un tri croissant sur les nombres situés à gauche du tiret
Tri Tbl
'résultat en feuille "Feuil2"
K = 1
For I = 1 To UBound(Tbl)
J = J + 1
Worksheets("Feuil2").Cells(J, K).Value = Tbl(I)
If I Mod Plage.Rows.Count = 0 Then K = K + 1: J = 0
Next I
End Sub
Sub Tri(Tbl() As String)
Dim Tempo
Dim I As Long
Dim J As Long
'effectue un tri décroissant "<"
'pour un tri croissant ">"
For I = 1 To UBound(Tbl) - 1: For J = I + 1 To UBound(Tbl)
If CInt(Left(Tbl(I), InStr(Tbl(I), "-") - 1)) > CInt(Left(Tbl(J), InStr(Tbl(J), "-") - 1)) Then
Tempo = Tbl(J): Tbl(J) = Tbl(I): Tbl(I) = Tempo
End If
Next J, I
End Sub
Function DefPlage(Fe As Worksheet, Optional L As Long = 1, Optional C As Long = 1) As Range
On Error GoTo Fin
With Fe
Set DefPlage = .Range(.Cells(L, C), _
.Cells(.Cells.Find("*", .[A1], -4123, , _
1, 2).Row, .Cells.Find("*", .[A1], -4123, , _
2, 2).Column))
End With
Exit Function
Fin:
Set DefPlage = Nothing
End Function