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: 49
Default For Each loop recheck

I have a for each loop that loops through a range of cells. My problem
is that if my criteria is met I delete the current row. The problem is
that the for each loop moves on to the next item which is really 1 more
down now that I deleted a row. How can I make it recheck the current
row? I basically want it to back up 1 and then let the for each move
ahead 1 to get me to the same line (which is the new one because of the
deleted row).

Here is the code I have.

Sub MoveCompleted()
Dim LastRow
For Each cell In Sheets("Master Project List").Range("I7:I500")
Debug.Print cell.Value
If cell < "" Then
Row = cell.Row
Sheets("Completed Projects").UsedRange '<<-- Reset Used
Range!!
LastRow = Sheets("Completed
Projects").Cells.SpecialCells(xlCellTypeLastCell). Row + 1
Sheets("Master Project List").Range(Row & ":" & Row).Cut
Sheets("Completed Projects").Range(LastRow & ":" & LastRow)
Sheets("Master Project List").Range(Row & ":" & Row).Delete
End If
Next cell
End Sub

Thanks
Scott

 
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
always recheck data connection library for latest connection strin FurmanGG Excel Discussion (Misc queries) 0 September 14th 07 04:48 PM
always recheck data connection library in MOSS for latest data sou FurmanGG Excel Discussion (Misc queries) 0 September 14th 07 04:48 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 06:56 AM.

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"