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 NonSortedListed()
Dim I As Long, J As Long
Dim TempArray As Variant
Dim LastSortedLine As Single
Dim LastLine As Single
Dim LastCol as Single
Dim Ws As Worksheet
Set Ws = Feuil1
With Ws
LastLine = .Columns(1).Find("*", , , , xlByRows, xlPrevious).Row
LastCol = .Rows(1).Find("*", , , , xlByRows, xlPrevious).Column
'Tu va déterminer la dernière ligne non vide de la colonne A, et la dernière colonne non vide de la ligne 1.
TempArray = .Range(.Cells(2, 1), .Cells(LastLine, LastCol))
LastSortedLine = 2
.Range("L2:M" & UBound(TempArray, 1) * UBound(TempArray, 2)).ClearContents
For I = LBound(TempArray, 1) To UBound(TempArray, 1)
For J = LBound(TempArray, 2) + 1 To UBound(TempArray, 2)
If TempArray(I, J) <> "" Then
.Cells(LastSortedLine, 12) = TempArray(I, 1)
.Cells(LastSortedLine, 13) = TempArray(I, J)
LastSortedLine = LastSortedLine + 1
End If
Next J
Next I
End With
End Sub |
Partager