LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default 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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop never ends NooK[_31_] Excel Programming 0 July 1st 04 08:46 AM
Loop never ends Bernie Deitrick Excel Programming 0 June 30th 04 07:00 PM
Loop never ends Bob Phillips[_6_] Excel Programming 0 June 30th 04 06:55 PM
Loop never ends Anson[_2_] Excel Programming 0 June 30th 04 06:08 PM
Loop ends early BrianB Excel Programming 0 August 15th 03 12:13 PM


All times are GMT +1. The time now is 07:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"