I am loading dates into a dynamic array and am getting error message, "run time error 9, subscript out of range" the dates on the spreadsheet are
formatted as date and look like 2/5/2005 in the formula bar, I tried using DateValue and DateSerial Function, no help. Stepping through the code it
has 2/5/2005 in the activecell.value. Below is my code, any ideas would be appreciated.
Public Type Material
MatNum As Integer
MatDate() As Date
End Type
Public MatType(10) As Material
Sub Load_Extraction_Dates_Into_Array()
Dim MatLoopCount, DateCount As Integer
MatLoopCount = 1
Sheets("Extraction Dates").Select
Range("A2").Select
For MatLoopCount = 1 To 10 'loop right through the ten columns of materials
DateCount = 1 'set/reset date count to beginning
MatType(MatLoopCount).MatNum = DateCount - 1 'start with date count at 0
Do Until ActiveCell.Value = ""
'on the next line I am getting a run time error 9, subscript out of range error message
MatType(MatLoopCount).MatDate(DateCount) = ActiveCell.Value
ActiveCell.Offset([1], [0]).Select 'advance down to next date
DateCount = DateCount + 1
Loop
Cells(1, ActiveCell.Column).Select 'take to row 1
ActiveCell.Offset([1], [1]).Select 'advance right to next column of material
Next ' end of looping through the ten columns of materials
End Sub
Bookmarks