I'm trying to teach myself about arrays and can't seem to figure this one out. (many Google searches)
I have the following code that I'm getting a 'subscript out of range' error:
<subscript out="" of="" range="">
In the "watch" window, MyArray is populating correctly and UBound(MyArray) provides the correct value, but the code produces an error at the 'If IsNumeric' line. "MyArray(i) = Subscript out of range <subscript out="" of="" range=""><subscript out="" of="" range="">" shows up when I hover over 'MyArray(i)'. What am I doing wrong?
</subscript>Thank you in advance for helping.</subscript></subscript>
I have the following code that I'm getting a 'subscript out of range' error:
<subscript out="" of="" range="">
Code:
Dim LastRow As Integer
Dim MyArray As Variant
Dim i As Integer
With Sheets("Testing")[INDENT]LastRow = .cells(.Rows.Count, 1).End(xlUp).Row
MyArray = Range("A5:A" & LastRow).Value
[/INDENT]
End With
For i = 0 To UBound(MyArray) - 1[INDENT]If IsNumeric(MyArray(i)) Then
(More code here)
[/INDENT]
Next
End Sub
In the "watch" window, MyArray is populating correctly and UBound(MyArray) provides the correct value, but the code produces an error at the 'If IsNumeric' line. "MyArray(i) = Subscript out of range <subscript out="" of="" range=""><subscript out="" of="" range="">" shows up when I hover over 'MyArray(i)'. What am I doing wrong?
</subscript>Thank you in advance for helping.</subscript></subscript>