Delete extra empty rows

  • Thread starter Thread starter gwc
  • Start date Start date
G

gwc

How can I delete all but one empty row between each row or group of
consecutive rows containing data?

Here is portion of my spreadsheet:

xxxxxxx
xxxxxxx
xxxxxxx
xxxxxxx
xxxxxxx



xxxxxxx
xxxxxxx
xxxxxxx

xxxxxxxx
xxxxxxxx






xxxxxxxx
xxxxxxxx
xxxxxxxx
xxxxxxxx
xxxxxxxx
xxxxxxxx
xxxxxxxx

xxxxxxxx
xxxxxxxx

xxxxxxxx




xxxxxxxxx
xxxxxxxxx
 
Sub deleteallbutoneblankrowSAS()
Dim i As Long
For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
If Cells(i, 1) = "" And Cells(i + 1, 1) = "" _
Then Rows(i + 1).Delete
Next i
End Sub
=======
 
Sub deleteallbutoneblankrowSAS()
Dim i As Long
For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
If Cells(i, 1) = "" And Cells(i + 1, 1) = "" _
Then Rows(i + 1).Delete
Next i
End Sub
=======




- Show quoted text -

Thanks.
 
Back
Top