Delete all rows where column A is blank

J

Jodie

I need to write a macro to delete all rows where column A is blank. Can
anyone help me with this please?
 
C

Chip Pearson

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]
 
G

Gord Dibben

Do you really need a macro?

Select column A

F5>Special>Blanks>OK

Edit>Delete>Entire Row


Gord Dibben MS Excel MVP
 
J

Jodie

Yes Gord, I will be adding this to another macro and be using it multiple
times for spreadsheets of different sizes.
 

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