Macro to delete specific number of rows.

[Closed]
Report
-
Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
-
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 reply

Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
486
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