Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a loop stephenc Excel Discussion (Misc queries) 4 January 12th 09 03:54 PM
create a loop Ivano Excel Programming 0 April 18th 06 06:01 PM
Is it possible to create variables in a loop.. shishi Excel Programming 2 February 3rd 06 07:21 PM
How do I create a For loop within a For loop? Linking to specific cells in pivot table Excel Programming 2 January 24th 05 08:05 AM
Macro to move, create formulas and loop NewMacro Excel Programming 5 February 2nd 04 10:12 PM


All times are GMT +1. The time now is 08:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"