Need a Macro that will delete every odd row starting at row number 1.

Need a Macro that will delete every odd row starting at row number 1.

Post by Brandon Ho » Wed, 26 Apr 2006 21:39:23


I have looked online and only found a macro that would delete every even row.
I have a recurring job that requires me to delete every odd row. Could
someone please help me with this.

Thanks,

Brandon
 
 
 

Need a Macro that will delete every odd row starting at row number 1.

Post by Bob Philli » Wed, 26 Apr 2006 21:42:17

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
If Int(iLastRow / 2) * 2 = iLastRow Then iLastRow = iLastRow - 1
For i = iLastRow To 1 Step -1
Rows(i).Delete
Next i

End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)



row.

 
 
 

Need a Macro that will delete every odd row starting at row number 1.

Post by Brandon Ho » Wed, 26 Apr 2006 23:41:44

Thanks Bob this one works perfect for me.