I am writing a section of code that would go through an array and set repeat values to "" (null). I am using a For-Next loop to look at each element in the array. on the first iteration of the loop i get the runtime error 9, subscript out of range. It is clear to me that the variable i am using falls within the declared array size and i have no idea why it would be out of range. the code is as follows.
ReDim tickerarr(numrows + numrowsday)
tickerarr = Workbooks("ML_" & year & ".xls").Worksheets(1).Range("a1:a" & numrows + numrowsday).Value
For i = 1 To numrows + numrowsday
If tickerarr(i) = tickerarr(i + 1) Then
tickerarr(i + 1) = ""
End If
Next i
when the error pops up:
numrows = 0
numrowsday = 1940
tickerarr = array filled with strings
i = 1
ReDim tickerarr(numrows + numrowsday)
tickerarr = Workbooks("ML_" & year & ".xls").Worksheets(1).Range("a1:a" & numrows + numrowsday).Value
For i = 1 To numrows + numrowsday
If tickerarr(i) = tickerarr(i + 1) Then
tickerarr(i + 1) = ""
End If
Next i
when the error pops up:
numrows = 0
numrowsday = 1940
tickerarr = array filled with strings
i = 1