Macro to delete specific number of rows.

Closed
Rahul - 6 Jun 2012 à 06:46
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 7 Jun 2012 à 09:37
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 12 September 2010 Status Contributor Last seen 27 December 2022 555
7 Jun 2012 à 09:37
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