PDA

View Full Version : Delete VB code



nedy_03
03-08-2007, 10:28 AM
Can anybody help me with a vb code that that do this:
I have let's say the rows : 1,2,3,4,5,6,7,8,9,10,11,12 .... the code should heep row 1 and delete 2,3,4; keep row 5 and delete 6,7,8; keep row 9 and delete 10,11,12 ... etc

Thx,
Nedy

Bob Phillips
03-08-2007, 10:41 AM
Sub DeleteData()
Dim iLastRow As Long
Dim i As Long

With ActiveSheet
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = ((iLastRow \ 4) - ((iLastRow Mod 4) <> 0)) * 4 To 1 Step -4
.Rows(i - 2).Resize(3).Delete
Next i
End With
End Sub

nedy_03
03-08-2007, 11:12 AM
Thx ...