LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default redim preserve the second dimension in a two-dim array

go back to your orginal thread to see the correction you need.

--
Regards,
Tom Ogilvy


"Arnold Klapheck" wrote:

My understanding is in a two dimensional array the second dimension has to be
the same length for each one, What I would like is to have the second
dimension to be different lengths so it only has to be the length to handle
the number of items.
not being able to do that I figure the next best thing is the find the max
number of items in the second dimension and "redim preserve" the second
dimension so I don't have excess number of items. However I am having trouble
doing this getting message that it has already been dimensioned. Anyone have
ideas on how to make this work? Thanks.

below is my code and what I am trying to do.

Public Type Material
MatNum As Integer
MatDate(1 To 30) As Date ' 30 is the max number needed
End Type

Sub Load_Extraction_Dates_Into_Array()

Dim MatLoopCount As Integer, DateCount As Integer, maxDateNum i As Integer

Sheets("Extraction Dates").Select

For MatLoopCount = 1 To 10
With MatType(MatLoopCount)
DateCount = 0
For i = 1 To Cells(Rows.Count, MatLoopCount).End(xlUp).Row - 1
.MatDate(i) = Cells(i + 1, MatLoopCount).Value
DateCount = DateCount + 1
Next
.MatNum = DateCount
if DateCount maxDateNum then ' add this
maxDateNum = DateCount 'add
end if ' add
End With
Next
redim preserve MatType.MatNum(1 to maxDateNum) 'this dosn't want to work
End Sub



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA syntax help: ReDim Preserve an array Dave Excel Discussion (Misc queries) 4 September 8th 07 07:37 PM
redim preserve [email protected][_2_] Excel Programming 3 December 15th 05 01:40 PM
how to redim more than one dimension in a multidimensional dynamic array? lvcha.gouqizi Excel Programming 8 October 28th 05 09:42 PM
Redim Preserve doesn't work Witek[_2_] Excel Programming 3 November 1st 04 11:34 PM
ReDim, Preserve and Multidimensional arrays Andy Westlake[_2_] Excel Programming 3 October 19th 04 07:04 PM


All times are GMT +1. The time now is 07:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"