Thread: Loop & Delete
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Sandy Mann Sandy Mann is offline
external usenet poster
 
Posts: 2,345
Default Loop & Delete

Jenna,

You should loop UP through the rows not down otherwise the count of the loop
will go wrong.

Try something like:

Sub DeleteIt()
Dim Starter
Dim c As Long


Starter = Cells(Rows.Count, 1).End(xlUp).Row

For c = Starter To 1 Step -1
'Change the 1 in Cells(c, 1) to the number of the column that yo want to
check
If Left(Cells(c, 1).Value, 5) = "Total" Then
Range(Cells(c, 1), Cells(c + 1, 1)).EntireRow.Delete
End If
Next c

End Sub

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


with @tiscali.co.uk


"jenna" wrote in message
...
Hii guys

Please help below

I need a procedure that will loop down column B, and delete any row with
the
first five letters = "Total" and the next row.


Thanks