I have some problem to use the function redim
preserve in VBA Excel.
I would like to redim
an array I already use in the macro before without clear the data already inside.
My macro is looking like that :
Dim table_data As Variant
...
ReDim table_data(2 * n + 2 * m + 2 * n, table_case.ListColumns.Count - 1)
...
dim1 = UBound(table_data, 1)
dim2 = UBound(table_data, 2)
ReDim Preserve table_data(0 To dim1 + 2 * n, 0 To dim2)
Do you have any idea what I should modify?
When using Preserve
keyword; you can change size only for the last dimension. The size of other dimensions once declared must remain unaltered.
The code below should work:
ReDim Preserve table_data(LBound(table_data, 1) To UBound(table_data, 1), 0 To dim2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.