Multi-Dimensional Array
hi noname,
here is an example, i hope this may help
'copy the table into a temporary array the same size.
'resize the table from two dimensions at once which in practice destroyed
'and recreated a table of the same name but different sizes
'pour the contents of the temporary array in the table "starting" resized. Table "start" should be resized larger than the table starting
'add new data in the table
Sub RedimArray_xD()
Dim Tblo() As Integer
Dim Tmp() As Integer
Dim a As Integer
Dim i As Integer, j As Integer
ReDim Tblo(3, 4)
For i = 1 To 3
For j = 1 To 4
a = i * 10 + j
Tblo(i, j) = a
Next j
Next i
ReDim Tmp(3, 4)
Tmp = Tblo
'depending on the version of Excel so can not work in this case using the loop below'For i = LBound(Tblo, 1) To UBound(Tblo, 1)
' For j = LBound(Tblo, 2) To UBound(Tblo, 2)
' Tmp(i, j) = Tblo(i, j)
' Next j
'Next i
ReDim Tblo(5, 7)
For i = LBound(Tmp, 1) To UBound(Tmp, 1)
For j = LBound(Tmp, 2) To UBound(Tmp, 2)
Tblo(i, j) = Tmp(i, j)
Next j
Next i
For i = 1 To 5
For j = 5 To 7
a = i * 100 + j
Tblo(i, j) = a
Next j
Next i
For i = 4 To 5
For j = 1 To 4
a = i * 100 + j
Tblo(i, j) = a
Next j
Next i
Range("A1").Resize(UBound(Tblo), 6) = Application.Transpose(Tblo)
End Sub
--
isabelle
|