View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
AG[_3_] AG[_3_] is offline
external usenet poster
 
Posts: 50
Default Macro does not delete all the required rows

Hi Everyone,

I have a datasheet (a daily report that I get from a system). In this
report I have column AE that contains the identifier for that row.
Some of the identifiers are DUMMY. These are wrong postings from the
system. I have written a following code to delete all rows that have
DUMMY in column AE.

Sub delete_dummy()
Dim Cell As Range
For each Cell in Range("AE:AE")
If Cell.Value = "DUMMY" Then
Cell.EntireRow.Delete
End If
Next Cell
End Sub

The code works but it does not delete all the rows containing dummy. I
have to run it a few times before all the dummy rows are deleted. I
have no idea why that happens and how to fix it so that all the dummy
items are deleted in one go. Can someone help me with this. Thanks
very much.

Regards,
-AG