Minggu, 25 Mei 2014

[ExcelVBA] Subscript out of range

 

Hello,
 
I am working on an exercise where I have 2 sets of numbers in 2 rows A1:E1 and A2:E2.
I am trying to populate these numbers in these into 2 arrays. The arrays are :
Dim r_1(1, 5) As Integer, Dim r_2(1, 5) As Integer
I am using nested For Loops to try and populate the values into the arrays:
For i = 1 To 2
    For j = 1 To 5
      r_1(row1, j) = Range(Cells(row1, i), Cells(row1, i)).Value
      r_2(row2, j) = Range(Cells(row2, i), Cells(row2, i)).Value
    Next j
 Next i
 
r_1(row1, j) = Range(Cells(row1, i), Cells(row1, i)).Value
This above is working and getting the right value into the array, but
 
r_2(row2, j) = Range(Cells(row2, i), Cells(row2, i)).Value
the above fails, with "Subscript out of range". I am not sure what is wrong.
 
Thanks in advance. Hope everyone's day is going well.
David

__._,_.___

Posted by: David <who1012000@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Posting Komentar