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 deletes seperately


Try from the bottom up
sub dr()
mc="I"
for i=cells(rows.count,mc).end(xlup).row to 2 step -1
if cells(i,mc)= "AMS" _
Or cells(i,mc)="Apollo" Then rows(i).delete
next i
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Zak" wrote in message
...
I have the following code to do 3 things, when i ran the macro it deleted
just the one thing, then i pressed run again then it did the other thing!
it
seemed i had to press run 3 times before the macro executed everything.
cant
the macro do them all at once or with just one click?

thanks alot.

Sub Delete_Rows()

Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("I:I"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Text) = "Covansys" _
Or (cell.Text) = "AMS" _
Or (cell.Text) = "Apollo" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.delete
End Sub