PDA

View Full Version : Solved: can anyone see what's wrong with this?



Eric58132
07-17-2009, 11:00 AM
Option Explicit
Sub Main()
Dim MyArray(1 To 12) As Integer
Dim i As Variant
Dim n As Variant
n = Sheets("Analysis").Range("A1").Value
For i = 0 To n
MyArray(i) = Sheets("Analysis").Cells(22, i + 7).Value
Next i
End Sub



edit: the error highlights the MyArray line, saying there is an invalid range

Bob Phillips
07-17-2009, 11:06 AM
You have declared thearray as 1 To 12 and are then trying to load item 0, which just ain't there.

Eric58132
07-17-2009, 11:11 AM
thanks!