Delete all rows where column A is blank

  • Thread starter Thread starter Jodie
  • Start date Start date
J

Jodie

I need to write a macro to delete all rows where column A is blank. Can
anyone help me with this please?
 
Try some code like the following. Change the value "Sheet1" to the
appropriate worksheet name.


Sub AAA()
Dim LastRow As Long
Dim RowNdx As Long
Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
With WS
LastRow = .UsedRange.SpecialCells(xlCellTypeLastCell) _
.EntireRow.Cells(1, "A")
For RowNdx = LastRow To 1 Step -1
If .Cells(RowNdx, "A").Value = vbNullString Then
.Rows(RowNdx).Delete
End If
Next RowNdx
End With
End Sub

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]
 
Do you really need a macro?

Select column A

F5>Special>Blanks>OK

Edit>Delete>Entire Row


Gord Dibben MS Excel MVP
 
Yes Gord, I will be adding this to another macro and be using it multiple
times for spreadsheets of different sizes.
 
Back
Top