if a cell equal to zero how can it delete entire row

G

Gary''s Student

For only a single cell, say cell Z100:


Sub demo()
If Range("Z100").Value = 0 Then
Range("Z100").EntireRow.Delete
End If
End Sub


For a range of cells, say all the cells in column Z

Sub demoi()
n = Cells(Rows.Count, "Z").End(xlUp).Row
For i = n To 1 Step -1
If Cells(i, "Z").Value = 0 Then
Cells(i, "Z").EntireRow.Delete
End If
Next
End Sub
 

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