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
| Sub Transf()
Dim LastLig As Long, i As Long
Dim LastCol As Integer, j As Integer, k As Integer, m As Integer
Dim TabErr
With Sheets("Feuil1")
LastLig = .Cells(Rows.Count, "A").End(xlUp).Row
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
ReDim TabErr(1 To 2, 1 To 1)
k = 1
For i = 2 To LastLig
For j = 3 To LastCol
If .Cells(i, j).Value > 0 Then
For m = 1 To Cells(i, j).Value
TabErr(1, k) = .Cells(i, 1).Value
TabErr(2, k) = .Cells(1, j).Value
k = k + 1
ReDim Preserve TabErr(1 To 2, 1 To k)
Next m
End If
Next j
Next i
End With
With Sheets("Feuil2")
.Range(.Cells(2, 1), .Cells(k + 1, 2)) = Application.Transpose(TabErr)
End With
End Sub |
Partager