How to delete rows in Excel using macros

0
Categories: Visual Basic
Posted on: 24th May 2009 by: Andrei

This code will run on the first column until it finds an empty cell. To change the column, modify the ’1′ with the desired column number in this line

While Cells(Cursor + StartRow, 1) <> ""

Here is the macro.

Sub Macro1()

Dim start As Integer ' row to start on
Dim i As Integer
Dim c As Integer

start = 2
c = 0
i = 1

While Cells(c + start, 1) <> ""
    If (i Mod 33 <> 0) Then
        Rows(CStr(c + start) & ":" & CStr(c + start)).Delete Shift:=xlUp
    Else ' skip row
        c = c + 1
    End If
    i = i + 1
Wend
End Sub