View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Macro must run multiple times before completion

You should have worked from the bottom up

Sub Delete()

Dim iLastRow As Long
for i=Cells(Rows.Count, "A").End(xlUp).Row to 2 step-1

mc-cells(i,"g")
'one line below
If mc = "FUNDED" Or mc= "DOCS-OUT" Or mc= "PURCHASED" Then rows(i).delete
'one line above

Next i
End Sub



--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"TMc21" wrote in message
...
I am trying to run a macro that will delete row if a certain keyword is
spotted, but I have to run the macro multiple times before it cleans out
the
spreadsheet completley. Below is what I have.

Sub Delete()
Dim myRange As Range
Dim iLastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set myRange = Range("G2:G" & LastRow)
For Each c In myRange
c.Select
If c.Value = "FUNDED" Or c.Value = "DOCS-OUT" Or c.Value = "PURCHASED"
Then
ActiveCell.EntireRow.Select
Selection.Delete
End If
Next
End Sub