• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Loop deleting rows

LakeAnnaMike

New Member
Excel Snip.png

I am trying to delete all odd rows (3,5,7,9, etc.). I wrote the following code

>>> use code - tags <<<
Code:
Sub Macro2()
Dim i As Integer
For i = 3 To 600
Rows(i).Select
    Selection.Delete Shift:=xlUp
Next i
End Sub

This used to work, but now it deletes 2 rows at a time. I am assuming this is because the cells are "broken". For example, it will delete rows 2 and 3 instead of just row 3.
Any suggestions as to how I can get it to just delete row 3 then row 4 etc.?


Appreciate the help.

Mike
 
Last edited by a moderator:
You didn't leave the Select and Selection.Delete lines in did you?
Don't have the macro selecting anything.
I tested this on merged cells myself and it was OK.
Otherwise attach the workbook.
 
You didn't leave the Select and Selection.Delete lines in did you?
Since we've not heard from @LakeAnnaMike for 11 days I can only presume this was the case.
It would be nice if people we try to help would give feedback and/or acknowledgement. It would also make it more likely they get help again, should they need it. We're not AI bots, we're human.
 
Back
Top