How can I delete rows programmatically based on certain criteria?

G

Guest

I have a large dataset in Microsoft Excel 2003 with almost 3000 lines and
I want to delete the rows of it, which have nulls in one or more of their
columns.
e.g.
A B C D
1 2 3 4
1 4 5
2 3 4
Result : The 2nd and 3rd rows will be deleted or someway discarded.
How can I do this?
 
G

Guest

Sub marine()
For i = 100 To 1 Step -1
If IsEmpty(Cells(i, "D")) Then
Cells(i, "D").EntireRow.Delete
End If
Next
End Sub

Adjust the 100 to meet your needs
 

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