Delete Row If Empty Macro

R

Richard

Using: MS OS XP
Excel 2003

I have tried and need some help for some VBA code in a macro.

I have a table of about 400 rows. The rows may vary but not be over 400. I
need to check the cells in column A. If the cell in column A is empty then I
want to delete the entire row and go and check the next cell in column A etc.

The rows may vary but they shouldn’t exceed 400.
 
D

Dave Peterson

And if you need a macro:

Option Explicit
Sub testme()
On Error Resume Next
ActiveSheet.Range("a:A").Cells.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
 
G

Gord Dibben

Richard

Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.UsedRange.Rows.Count
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "A").Value = "" Then
Rows(RowNdx).Delete
End If
Next RowNdx
End Sub

Note: you don't need a macro to do this.

Select column A and F5>Special>Blanks>OK

Edit>Delete>Entire Row.


Gord Dibben MS Excel MVP
 
Top