Macro to delete blank rows in a worksheet

  • Thread starter Thread starter adchris
  • Start date Start date
A

adchris

I am attempting to create a macro that will eliminate blank rows from a tab
in a worksheet. I need to do this in order to maintain the "auto-complete"
functionality.
 
Hi,

Right click your sheet tab, view code and paste this in and run it

Sub Sonic()
Dim i As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = lastrow To 1 Step -1
If WorksheetFunction.CountA(Rows(i)) = 0 Then
Rows(i).EntireRow.Delete
End If
Next i
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub

Mike
 
Do you need a macro?

Select a column with the blank rows and F5>Special>Blanks>OK

Edit>Delete>Entire Row.


Gord Dibben MS Excel MVP
 

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

Back
Top