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 39 40 41 42 43 44
|
Sub Test()
Dim Tbl()
Dim Index As Long
Dim X As Long
Dim Y As Long
Dim I As Long
Dim J As Long
X = 9 'colonnes (colonne A à I)
Y = 40 'lignes (ligne 1 à 40)
'redimensionne le tableau en ajoutant une colonne en plus pour les index
ReDim Tbl(1 To X + 1, 1 To Y)
For I = 1 To Y 'par ligne
Index = Index + 1
Tbl(1, I) = Index 'la première colonne sert aux index
For J = 2 To X + 1 'par colonne
'commence à A1, B1, C1...
'A2, B2, C2...
'A3, B3, C3...
'etc...
Tbl(J, I) = Cells(I, J - 1).Value
Next J, I
'pour le test, inscrit les valeurs à partir de K1 (colonne K, les index)
For I = 1 To UBound(Tbl, 2)
For J = 1 To UBound(Tbl, 1)
Cells(I, J + 10).Value = Tbl(J, I)
Next J, I
'ou directement en transposant...
Range(Cells(1, 11), Cells(UBound(Tbl, 2), UBound(Tbl, 1) + 10)) = Application.WorksheetFunction.Transpose(Tbl())
End Sub |
Partager