Simple VBA Deletion of certain rows.

M

Mathew P Bennett

Good evening all.
this seems so simple but I have tried searching Google, but to no avail. And
so I do hope someone can help me here.

I am simply looking for code to delete the rows that have Zero in Column C,
a simple example as follows:
Formats: A=Text, B=Text, C=Number

A B C
1 Header Header Header
2 003 M080 85.26
3 005 M080 0.00
4 004 M076 25.25
5 002 M085 0.00
6 006 M564 0.00
7 001 K798 96.58

I would like code to delete the entire row that has value 0.00 in Column
C,(a calculated cell), so the outcome will be:

A B C
1 Header Header Header
2 003 M080 85.26
3 004 M076 25.25
4 001 K798 96.58

Any help, as usual would be gratefully received.
Cheers
Mathew
 
D

Dave Smith

Try somthing like this:

Sub DeleteZeroRows()
Dim i As Long

i = 1
Do While Not IsEmpty(Cells(i, 3).Value)
If Cells(i, 3).Value = 0 Then
Rows(i).Delete
Else
i = i + 1
End If
Loop
End Sub

This will delete rows where column C contains 0 until it hits an empty cell
in Column C.

HTH

-Dave
 

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