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
| Option Explicit
Option Base 1
Private Sub TriageDonnees()
Dim intLigne, intCol, i, j, k As Integer
Dim strTrajet() As String
With Sheets("Parcours")
intLigne = .Range("A" & .Rows.Count).End(xlUp).Row
intCol = .Cells(1, .Cells.Columns.Count).End(xlToLeft).Column
ReDim strTrajet(intLigne * (intCol - 3), 4)
k = 1
For i = 2 To intLigne
intCol = .Cells(i, .Cells.Columns.Count).End(xlToLeft).Column
For j = 3 To intCol
If .Cells(i, j + 1) <> "" Then
strTrajet(k, 1) = .Cells(i, 1)
strTrajet(k, 2) = .Cells(i, 2)
strTrajet(k, 3) = .Cells(i, j)
strTrajet(k, 4) = .Cells(i, j + 1)
k = k + 1
End If
Next j
Next i
End With
With Sheets("Détails")
.Range(.Cells(2, 1), .Cells(UBound(strTrajet, 1), UBound(strTrajet, 2))) = strTrajet
End With
End Sub |
Partager