create a loop macro
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. |
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. |
All times are GMT +1. The time now is 02:49 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com