loop ends unexpectedly before finishing loop
Sub MoveDone()
Dim i As Integer, ii As Integer
Worksheets("CIT291").Activate
For i = LastRow(ActiveSheet) To 2 Step -1
With Range("a" & i)
If UCase(.Value) = "DONE" Then
Rows(i).Cut Sheets("CIT291_History").Rows(LastRow(Worksheets(" CIT291_History")) + 1)
End If
End With
Next i
End Sub
when the true event occurs, the cut/paste functions properly, but then the code ends. I cannot for the life of me figure out why. there is no other code in the module other than the lastrow() function. Here's the lastrow() function I'm using:
Function LastRow(sh As Worksheet)
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
End Function
|