When deleting rows, it is always best to work from the bottom up,
rather than the top down.
Dim RowNdx As Long
For RowNdx = LastRow To 2 Step -1
If Something = True Then
Rows(RowNdx).Delete
End If
Next RowNdx
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
On Tue, 21 Oct 2008 11:37:35 -0700 (PDT), Dudely
wrote:
I've tried this two different ways, neither seems to work quite right.
Set sentWS = ThisWorkbook.Worksheets("Sent")
lastRow = sht.UsedRange.Rows.count 'last row of current sheet
currentRow = sentWS.UsedRange.Rows.count 'last row of sent sheet
currentRow = currentRow + 1
While lastRow 1
Set cell = sht.Range("A" & lastRow)
cell.EntireRow.Copy sentWS.Range("A" & currentRow)
(1) cell.Rows(lastRow).Delete
(2) cell.EntireRow.Delete
currentRow = currentRow + 1
lastRow = lastRow - 1
Wend
The line labeled (1) above fails to do anything at all, and the line
labeled (2) deletes the first line instead of the last line.
The copy works just fine, as does the rest of the code.
So what am I doing wrong please?
Thank you