VB to find text and delete that row and three beneath it

D

Darin Kramer

Hi There,

I have a large amount of consolidated data on a sheet called Master. I
need some VB that looks only in column F for the word "Cleared". When it
finds it, needs to select that line, and 3 beneath it (ie four in total)
and delete those 4 rows, then move on to the next instance of cleared,
select the 3 rows beneath it and delete all four rows, etc etc for all
instances in that column....

Any ideas?

Regars

D

*** Sent via Developersdex http://www.developersdex.com ***
 
M

Mike H

Darin,

Right click the sheet tab, view code and paste this in:-

Sub sonic()
lastrow = Range("F65536").End(xlUp).Row
For x = lastrow To 1 Step -1
Cells(x, 6).Select
If ActiveCell.Value = "Cleared" Then
ActiveCell.EntireRow.Select
Selection.Resize(4, 256).Select
Selection.Delete Shift:=xlUp
End If
Next
End Sub


Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top