Macro to delete specific number of rows.

Closed
Rahul - Jun 6, 2012 at 06:46 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jun 7, 2012 at 09:37 AM
Hello,

i have a imported text file into exel and i want to delete some specific number of rows after specific number of row say i want to delete 7 unwanted rows after every 50 rows to get uhge data in proper single row. please help me to creat macro for that.Thank you.

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Jun 7, 2012 at 09:37 AM
Hi Rahul,

Here you go:
Sub DeleteRows()
Dim lRow, x, y As Integer

lRow = Range("A" & Rows.Count).End(xlUp).Row
x = 1

Do
x = x + 50
Rows(x & ":" & x + 6).ClearContents
Loop Until x > lRow

For y = lRow To 1 Step -1
If Range("A" & y).Value = vbNullString Then Rows(y).Delete
Next y
    
End Sub

Best regards,
Trowa
0