PDA

View Full Version : Solved: Range matrix



pepe90
07-11-2011, 08:10 AM
Hello, I'm kind of noob on OOP so I'm having some problems on lines like this one:

Sheets("SIMULACIÓN").Activate
Dim pos_canaletas(1 To 34) As Range
For i = 1 To 34
If i <= 8 Then
pos_canaletas(i) = ActiveSheet.Range(Cells(i1, 4), Cells(i1, 8))
i1 = i1 + 2
ElseIf i <= 11 Then
pos_canaletas(i) = ActiveSheet.Range(Cells(i2, 4), Cells(i2, 8))
i2 = i2 + 2
ElseIf i <= 14 Then
pos_canaletas(i) = ActiveSheet.Range(Cells(i3, 13), Cells(i3, 18))
i3 = i3 - 2
ElseIf i <= 22 Then
pos_canaletas(i) = ActiveSheet.Range(Cells(i4, 13), Cells(i4, 18))
i4 = i4 - 2
ElseIf i <= 28 Then
pos_canaletas(i) = ActiveSheet.Range(Cells(4, j1), Cells(9, j1))
j1 = j1 + 2
Else
pos_canaletas(i) = ActiveSheet.Range(Cells(13, j2), Cells(18, j2))
j2 = j2 + 2
End If
Next

I'm getting an error message on the 5th line (pos_canalestas(i)...) that says something like "Object variable or With block not defined" (91).

Thanks fot your help

Kenneth Hobs
07-11-2011, 10:17 AM
Dim pos_canaletas(1 To 34) as a String or a Variant.

pepe90
07-11-2011, 11:38 AM
Thanks a lot, it works :)