I have some sample code here which is similar to what I saw in a book. The
only diference is that I'm using a range of cells from Excel and the book
used a recordset to populate the array. I'm getting the err msg:
"Subscript Out Of Range" on the 9th line:
"Debug.Print varA(iRow, iCol);"
when this code loops through the first time, both iRow and iCol equal "0".
Thats where it errors. If I set the begining value for iRow and iCol to "1"
then it runs OK unitil the last loop where iCol is one integer too high.
Please advise on the proper way to loop through an array like this.
Thanks.
Private Sub MakeRangeArray()
'On Error GoTo err_TestErr
Dim varA As Variant
Dim iCol As Integer
Dim iRow As Integer
varA = Worksheets("Sheet3").Range("C5:I12")
For iRow = 0 To UBound(varA, 2)
For iCol = 0 To UBound(varA, 1)
Debug.Print varA(iRow, iCol);
Next iCol
Debug.Print
Next iRow
err_TestErr:
If Err.Number = 9 Then Resume Next
End Sub
--
George Padvorac
nwis.net