Delete every 2nd and 3rd row- VBA
Quote:
>I am using XL 2000 and am in need of a macro but have very limited VBA
>experience.
>Here is what I have been trying to do with a file:
>row 1
>row 2 delete
>row 3 delete
>row 4
>row 5 delete
>row 6 delete
>row 7
>I want to delete every 2nd and 3rd row, but am having problems trying to
>record the macro. I used Chip Pearson's deleting duplicate entries
>macro and it worked great. But the file will not always have an easy to
>identify duplicate record field.
Here's one method. I assume you want to keep rows 1, 4, 7, etc, as you show. I
locate the last row of data by looking at column A.
Dim R As Long
R = Cells(Rows.Count, 1).End(xlUp).Row
Select Case R Mod 3
Case 0: R = R - 1
Case 1: R = R - 2
End Select
For R = R To 2 Step - 3
Rows(R).Resize(2).EntireRow.Delete
Next R