Sub Trier_CSV()
Dim fichier$, x%, titres$, texte$, s, a(), b(), n&, c(), i&
fichier = ThisWorkbook.Path & "\Fichier CSV.csv"
x = FreeFile
Open fichier For Input As #x 'ouverture en lecture séquentielle
Line Input #x, titres '1ère ligne avec titres
While Not EOF(x)
Line Input #x, texte
s = Split(texte & ",", ",") 'au moins 1 virgule
ReDim Preserve a(n): a(n) = s(1)
ReDim Preserve b(n): b(n) = texte
n = n + 1
Wend
Close #x
'---transposition---
ReDim c(1 To n, 1 To 2)
For i = 0 To n - 1
c(i + 1, 1) = b(i)
c(i + 1, 2) = a(i)
Next i
'---restitution---
Application.ScreenUpdating = False
With [A2]
.Cells(0) = titres
.Resize(n, 2) = c
.Resize(n, 2).Sort .Cells(1, 2), xlAscending, Header:=xlNo 'tri
.Cells(1, 2).Resize(n).ClearContents 'efface la colonne auxiliaire B
.Offset(n).Resize(Rows.Count - n - .Row + 1).ClearContents 'RAZ en dessous
End With
End Sub