Minggu, 25 Mei 2014

RES: [ExcelVBA] Subscript out of range

 

By using a multidimensional Array, keep in mind that when referring to it, the first term refers to the row and the second column.
As your Array has only one line (both), to refer to the same as line 2 generates the error.

 

The correc for the array twe is r_2(ROW1,j)…..

 

De: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com]
Enviada em: domingo, 25 de maio de 2014 16:52
Para: excelvba@yahoogroups.com
Assunto: [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: "Reinaldo-Yahoo" <reinaldomarco@yahoo.com.br>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)
----------------------------------
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