|
ささ さん、ウッシ さん、こんばんは。
Redim Preserve 〜は、この場合使用できませんね!!
単純に大きい配列を用意してみては?
'=============================================
Sub test()
ReDim a(2, 30)
For idx = 0 To 2
For jdx = 0 To 30
a(idx, jdx) = idx + jdx
Next
Next
Range(Cells(1, 1), Cells(UBound(a(), 1) + 1, UBound(a(), 2) + 1)).Value = a()
MsgBox "ok"
a() = special_redim(a(), 6, 30)
MsgBox LBound(a(), 1) & ":::" & UBound(a(), 1)
MsgBox LBound(a(), 2) & ":::" & UBound(a(), 2)
Cells.ClearContents
Range(Cells(1, 1), Cells(UBound(a(), 1) + 1, UBound(a(), 2) + 1)).Value = a()
End Sub
'==================================================================
Function special_redim(myarray(), x, y)
'但し、x>=ubound(myarray(),1) ,y>=ubound(myarray(),2)
ReDim wk(LBound(myarray(), 1) To x, LBound(myarray(), 2) To y) As Variant
For idx = LBound(myarray(), 1) To UBound(myarray(), 1)
For jdx = LBound(myarray(), 2) To UBound(myarray(), 2)
wk(idx, jdx) = myarray(idx, jdx)
Next jdx
Next idx
special_redim = wk()
End Function
|
|