Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
"jenna" wrote in message
... Do i have to place my cursor at the bottom of the column? You don't have to place the cursor any where in particular My apologies, I failed to notice that you asked the procedure to look at Column B - I really should learn how to read! Use the Macro: Sub DeleteIt() Dim Starter Dim c As Long Starter = Cells(Rows.Count, 2).End(xlUp).Row For c = Starter To 1 Step -1 If Left(Cells(c, 2).Value, 5) = "Total" Then Range(Cells(c, 2), Cells(c + 1, 2)).EntireRow.Delete End If Next c End Sub In this line: Starter = Cells(Rows.Count, 2).End(xlUp).Row the row number of the last filled cell in column 2 (ie Column B) is loaded in the the variable *Starter* this number is then used as the start of the loop For c = Starter To 1 Step -1 which then steps UP through the column looking for a cell with *Total* in it. Also how do i delete the previous row too You originally said: first five letters = "Total" and the next row the range in: Range(Cells(c, 2), Cells(c + 1, 2)).EntireRow.Delete is the row in which *Total* was found *and* the row below it ie Cells(c, 2) is the cell in which *Total* was found and Cells(c + 1, 2) is the next cell down (ie row c+1) If you do want the *previous row* to be deleted then change the line then post back again. .. -- HTH Sandy In Perth, the ancient capital of Scotland and the crowning place of kings with @tiscali.co.uk "jenna" wrote in message ... Thanks so far Do i have to place my cursor at the bottom of the column? Also how do i delete the previous row too thaks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to Delete Rows in Excel In a Do Loop | Excel Worksheet Functions | |||
Adding a loop to conditional delete code | New Users to Excel | |||
I can't delete a cell without deleting a row | Excel Discussion (Misc queries) | |||
Loop time seems dependent on unrelated workbook - Why? | Excel Worksheet Functions | |||
Do Loop | Excel Discussion (Misc queries) |