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
| Option Explicit
Private MatriceA() As Variant
Private MatriceB() As Variant
Sub ChargerLesMatrices()
Dim I As Long
Dim J As Long
Dim AireACopier As Range
'MsgBox (ActiveSheet.Range("AireMatriceA").Rows.Count)
Set AireACopier = ActiveSheet.Range("AireMatriceA")
ReDim MatriceA(AireACopier.Rows.Count - 1, AireACopier.Columns.Count - 1)
For I = 0 To AireACopier.Rows.Count - 1
For J = 0 To ActiveSheet.Range("AireMatriceA").Columns.Count - 1
MatriceA(I, J) = Cells(AireACopier.Rows(I + 1).Row, AireACopier.Columns(J + 1).Column).Value
Next J
Next I
' MsgBox (MatriceA(UBound(MatriceA, 1), UBound(MatriceA, 2)))
ReDim MatriceB(AireACopier.Rows.Count - 1, AireACopier.Columns.Count - 1)
MatriceB = MatriceA
MsgBox (MatriceB(UBound(MatriceB, 1), UBound(MatriceB, 2)))
' On ajoute 3 colonnes
ReDim Preserve MatriceB(UBound(MatriceB, 1), UBound(MatriceB, 2) + 3)
MatriceB = Range(AireACopier, AireACopier.Offset(0, 3)).Value
MsgBox (MatriceB(UBound(MatriceB, 1), UBound(MatriceB, 2)))
Set AireACopier = Nothing
End Sub |
Partager