S
shelfish
Hi.
I'm having some difficulty with a for..next that is exiting early.
There is no error thrown. See code below...
ReDim b(1 To lastRow) 'VERIFIED TO BE OF VALUE 3123
For i = 1 To lastRow
With Cells(1, 1).Offset(i, 0)
b(i) = Trim(unit(.Offset(i, 1), .Offset(i, 2)))
End With
Next
The 'unit' function just concatenates the values...
Function unit(model As String, serial As String) As String
Nowhere in the function is the value of i changed. It is only used
once in a debug.print statement....
Debug.Print i & " = " & unit
This all works perfectly right up until i = 1561, which is half of the
lastRow. Why it would fail there I don't know. The value in the cells
to be concatenated for i = 1561 is identical to the values for 1562,
but 1562 fails inside the function....
Function unit(model As String, serial As String) As String
'VALIDATE ARGS
If Not (Len(model)) > 0 Or Not (Len(serial)) > 0 Then
unit = "x"
Exit Function
End If
So again, everything i = 1 to 1561 passes just fine and everything
after, i = 1562 to 3123 fails
Thanks for any assistance you can offer.
Shelton
I'm having some difficulty with a for..next that is exiting early.
There is no error thrown. See code below...
ReDim b(1 To lastRow) 'VERIFIED TO BE OF VALUE 3123
For i = 1 To lastRow
With Cells(1, 1).Offset(i, 0)
b(i) = Trim(unit(.Offset(i, 1), .Offset(i, 2)))
End With
Next
The 'unit' function just concatenates the values...
Function unit(model As String, serial As String) As String
Nowhere in the function is the value of i changed. It is only used
once in a debug.print statement....
Debug.Print i & " = " & unit
This all works perfectly right up until i = 1561, which is half of the
lastRow. Why it would fail there I don't know. The value in the cells
to be concatenated for i = 1561 is identical to the values for 1562,
but 1562 fails inside the function....
Function unit(model As String, serial As String) As String
'VALIDATE ARGS
If Not (Len(model)) > 0 Or Not (Len(serial)) > 0 Then
unit = "x"
Exit Function
End If
So again, everything i = 1 to 1561 passes just fine and everything
after, i = 1562 to 3123 fails
Thanks for any assistance you can offer.
Shelton