K
Keith R
Per XL2003's Redim help: If you use the Preserve keyword, you can resize
only the last array dimension and you can't change the number of dimensions
at all.
I declared/filled my arrays by assigning a range to my array variant, which
organizes my array as [1 to X rows, 1 to Y columns]. However, I need to add
additional rows while my code is running, and Excel automatically makes that
the first dimension- so apparently I can't Redim it?
Is there a way to either force Excel to assign the range in the reverse
order to my array [1 to Y columns, 1 to X rows] so I can use the redim (and
re-write all of my code to match), or is there a better way to do this? I'll
need to paste the array back to a worksheet range when the macro ends, in
case that affects which solution I should use.
Thank you,
Keith
Option Base 1
Public ExpediteArray As Variant '(1 To x rows, 1 To 40 columns)
Sub MyStuff
Expedite_LastRow = Sheet4.Cells.Find(What:="*", After:=[A1],
SearchDirection:=xlPrevious).Row
ExpediteArray = Sheet4.Range("A1:AN" & CStr(Expedite_LastRow)).Value
'then later
ReDim Preserve ExpediteArray(LBound(ExpediteArray, 1) To
UBound(ExpediteArray, 1) + 1, LBound(ExpediteArray, 2) To
UBound(ExpediteArray, 2))
End sub
only the last array dimension and you can't change the number of dimensions
at all.
I declared/filled my arrays by assigning a range to my array variant, which
organizes my array as [1 to X rows, 1 to Y columns]. However, I need to add
additional rows while my code is running, and Excel automatically makes that
the first dimension- so apparently I can't Redim it?
Is there a way to either force Excel to assign the range in the reverse
order to my array [1 to Y columns, 1 to X rows] so I can use the redim (and
re-write all of my code to match), or is there a better way to do this? I'll
need to paste the array back to a worksheet range when the macro ends, in
case that affects which solution I should use.
Thank you,
Keith
Option Base 1
Public ExpediteArray As Variant '(1 To x rows, 1 To 40 columns)
Sub MyStuff
Expedite_LastRow = Sheet4.Cells.Find(What:="*", After:=[A1],
SearchDirection:=xlPrevious).Row
ExpediteArray = Sheet4.Range("A1:AN" & CStr(Expedite_LastRow)).Value
'then later
ReDim Preserve ExpediteArray(LBound(ExpediteArray, 1) To
UBound(ExpediteArray, 1) + 1, LBound(ExpediteArray, 2) To
UBound(ExpediteArray, 2))
End sub