M
miek
When i try to redim my array i get an out of range error. can someone tel me
why?
Cells A1..A10 are filled with strings. thanks much
Sub Get_names_array()
Dim names_array() As Variant 'dynmanic
Dim j As Long
ReDim names_array(5, 1)
j = 0
Range("A1").Select
For i = 1 To 10
names_array(j, 0) = ActiveCell.Value
names_array(j, 1) = ActiveCell.Address
arraylimitFirst = UBound(names_array, 1) 'returns current dimension of 1st
array limit, init = 5
If j >= arraylimitFirst Then
ReDim Preserve names_array(10, 1) ' << RANGE ERROR 9 SUBSCRIPT OUT OF RANGE
j = j + 1
End If
ActiveCell.Offset(1, 0).Select 'down one
j = j + 1
Next i
End Sub
why?
Cells A1..A10 are filled with strings. thanks much
Sub Get_names_array()
Dim names_array() As Variant 'dynmanic
Dim j As Long
ReDim names_array(5, 1)
j = 0
Range("A1").Select
For i = 1 To 10
names_array(j, 0) = ActiveCell.Value
names_array(j, 1) = ActiveCell.Address
arraylimitFirst = UBound(names_array, 1) 'returns current dimension of 1st
array limit, init = 5
If j >= arraylimitFirst Then
ReDim Preserve names_array(10, 1) ' << RANGE ERROR 9 SUBSCRIPT OUT OF RANGE
j = j + 1
End If
ActiveCell.Offset(1, 0).Select 'down one
j = j + 1
Next i
End Sub