View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default create a loop macro

Sub DeleteData()
Dim rng As Range
Dim target As String
target = InputBox("Enter Search Term")
If target = "" Then Exit Sub
Do
If Not rng Is Nothing Then
rng.Resize(8, 1).EntireRow.Delete
End If
Set rng = Nothing
Set rng = Cells.Find(What:=target, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
Loop While Not rng Is Nothing
End Sub


obviously test this on a copy of your workbook/data.

--
Regards,
Tom Ogilvy


"andresg1975" wrote:

how can i create a macro that look for a data in a cell, delete the row in
that cell, delete 7 rows down, and repeat the action until it find no more
cells containing the data. Thanks so much for your help.