Delete row with empty cell in column

G

Gene Augustin

I have a worksheet with a column named DATE. Some of the date cells are
empty. I want a macro to delete all of the rows in which the date cell is
empty.


Gene Augustin
 
S

Sheeloo

Try after changing A in the second row to the column you having DATE

Sub deleteRow()
ColumntoDelete = "A"
For i = Cells(Rows.Count, ColumntoDelete).End(xlUp).Row To 1 Step -1
If Cells(i, ColumntoDelete) = "" Then Cells(i, "A").EntireRow.Delete
Next i
End Sub
 
S

Shane Devenshire

Hi,

Here is code to delete all rows which have blank cells in column A. You can
modify this to delete all cells of many different types and for any column.

Sub DeleteRows()
Range("A1:A" &
Range("A65536").End(xlUp).Row).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

The advantage of this type of code is it uses Excel's built in feature and
therefor runs very fast, in fact, between 60-100 times faster than loops.

In this case I am deleting the entire row but you can replace the
..EntireRow.Delete with .Delete Shift:=XLUp
 
C

Chris Bode

Place a control box on the sheet from the control box.
Double click the command button to open code window and paste followin
codes

Code
-------------------

Private Sub CommandButton1_Click()
Dim row As Integer, col As Integer
row = 1
col = 1

For row = 1 To 100
If Sheet1.Cells(row, col).Value = "" Then
Sheet1.Rows(row).Delete
End If
Next
End Sub

-------------------




Chris
 

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