Hpw do I delete multiple empty rows found between filled rows?

B

Bill

My data spreadsheet contains multiple empty rows found among thousands of
filled rows. Is there a way to delete the empty rows collectively without
having to do each one separately?
Thank you
 
G

Gary''s Student

Try this small macro:

Sub macro_der()
Dim i As Long, nLastRow As Long
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
Set r = Rows(nLastRow + 1)
For i = 1 To nLastRow
If Application.CountA(Rows(i)) = 0 Then
Set r = Union(r, Rows(i))
End If
Next
r.Delete
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top