VBA Code for Deleting a Row

  • Thread starter christopher.margol
  • Start date
C

christopher.margol

I would like to use a macro to delete any row that has the word
"delete" in one of its cells. What would this code be? Thanks!
 
G

Gary''s Student

Sub zero()
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
For i = nLastRow To 1 Step -1
For j = 1 To Columns.Count
v = Cells(i, j).Value
If InStr(1, v, "delete") > 0 Then
Cells(i, j).EntireRow.Delete
Exit For
End If
Next
Next
End Sub
 
D

Don Guillett

Try recording a macro
data>filter>autofilter>filter on delete>delete>autofiter
or
look in the vba help index for FINDNEXT.
 
Top