Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro for deleting rows and serialising the remaing rows | Links and Linking in Excel | |||
Macro for deleting rows and serialising the remaing rows | Setting up and Configuration of Excel | |||
Macro for deleting rows and serialising the remaing rows | Excel Worksheet Functions | |||
Help!!! I have problem deleting 2500 rows of filtered rows | Excel Programming | |||
deleting hidden rows so i can print only the rows showing?????? | Excel Worksheet Functions |