how can i create a macro

G

Guest

how can i create a macro that in column "D", look for first cell with a
value, go down until blank cell, delete three rows down, and continue the
same procedure.

lets say:

column D

row 5 100
row 6 200
row 7 blank
row 8 500
row 9 blank
row 10 400
row 11 80
row 12 blank
row 13 90
row 14 blank
row 15 100
row 16 300

result should be:

column D

row 5 100
row 6 200
row 400
row 80
row 100
row 300

thanks a lot
 
G

Guest

Not sure what your trying to do but I was able to replicate your example

Sandy

Sub TripleDelete()
Dim MyRange As Range, MyCells As Object, i As Integer
Set MyRange = [D:D]
For Each MyCells In MyRange
If MyCells.Value = Empty Then
Range(MyCells.Address, _
MyCells.Offset(2, 0).Address).EntireRow.Delete
End If
Next MyCells
End Sub
 
G

Guest

This should accomplish your purpose.

Sub test()

Range("D5").activate
Do
If Activecell = "" then
Range(Activecell, Activecell.Offset(2,0)).select
Selection.EntireRow.Delete shift:=xlUp
else
Activecell.Offset(1,0).Activate
end if
Loop until (whatever conditions you wish to set)
End Sub
 
G

Guest

I want to loop until there is no more cells with values
how can i do that, thanks a lot
 

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