Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redim Preserve Question 1

Status
Not open for further replies.
Apr 9, 2002
102
US
I am attempting to redim my multi-level array as I am creating it, but I keep running into problems. I can not find a way to redim preserve my multi-level array. Here is the code that I am currently using:

Do Until xlWorksheet.Application.ActiveCell.Value = ""
intCountAct = intCountAct + 1
ReDim Preserve arrActDump(intCountAct, 3)
arrActDump(intCountAct, 1) = & _ xlWorksheet.Application.ActiveCell.Value
arrActDump(intCountAct, 2) = & _ xlWorksheet.Application.ActiveCell.Offset(0, 2).Value
arrActDump(intCountAct, 3) = & _ xlWorksheet.Application.ActiveCell.Offset(0, 4).Value
xlWorksheet.Application.ActiveCell.Offset(1, 0).Select
Loop

The code basically loops through an excel workbook and counts each cell that has a value. Then the code redims the array so that the new values will fit into the array. When I attempt to redim preserve the second time through the loop I get an error. Any help is much appreciated.

Marrow
 
You can only redim and hope to preserve on one of the dimensions of a multi-dimensional array. I think the dimension you can change without penalty is the last one, so if you restructure your array so you can use
ReDim Preserve arrActDump(3,intCountAct)
I think you'll be allright.

Rob
[flowerface]
 
Thanks for the fast response. Your suggestion works great. * for u.

Marrow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top