Deleting alternae rows [Solved/Closed]

Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Hello,
I want to delete every alternate rows from my work sheet. I tried recording macro, but it only deletes a particular row as shown in macro below (Rows 4:4). Can we do something to it so that i can delete alternate rows with no hassles.. Since I am not trained as a programmer, I will appreciate if anybody can help me out in doing so..
below is the macro i recorded

Sub Macro3()
'
' Macro3 Macro
'
' Keyboard Shortcut: Ctrl+q
'
Rows("4:4").Select
Selection.Delete Shift:=xlUp
End Sub

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
760
Sub deleteAlternateRow()

Dim startAtRow, endAtRow, rowCounter As Long

startAtRow = 2
endAtRow = 100


For rowCounter = startAtRow To endAtRow
    Rows(rowCounter).Select
    Selection.Delete Shift:=xlUp
Next
End Sub
2
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 3122 users have said thank you to us this month

Wow!!!!....
It has worked.
Thanks a lot. :)
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
760 > abthak
Glad it worked out for you. I have just mailed you the bill :p~~ kidding