S
sbitaxi
Hi -
I'm using the following code in several places. Initially I had
simplified things by letting the Rng values pile up before passing the
Delete statement. Unfortunately, I realized that the various searches
I used occasionally came up with the same row for a different search
criteria. When I ran the delete, it deleted all the rows in the range,
but if a row appeared several times, it deleted valid rows as well.
This was originally a filter, but I thought performing one delete
rather than many would be better.
Thoughts?
Steven
Set FoundCell = SrcHdrRng.Find(What:="Event ID")
For Each MyCell In Range(FoundCell.Address, Cells(SrcLast,
FoundCell.Column).Address)
If MyCell.Value = "Tribute" Then
If Rng Is Nothing Then
Set Rng = Rows(MyCell.Row & ":" &
MyCell.Row)
Else: Set Rng = Union(Rng,
Rows(MyCell.Row & ":" & MyCell.Row))
End If
End If
Next
If Not Rng Is Nothing Then
Rng.Delete
End If
Set Rng = Nothing
I'm using the following code in several places. Initially I had
simplified things by letting the Rng values pile up before passing the
Delete statement. Unfortunately, I realized that the various searches
I used occasionally came up with the same row for a different search
criteria. When I ran the delete, it deleted all the rows in the range,
but if a row appeared several times, it deleted valid rows as well.
This was originally a filter, but I thought performing one delete
rather than many would be better.
Thoughts?
Steven
Set FoundCell = SrcHdrRng.Find(What:="Event ID")
For Each MyCell In Range(FoundCell.Address, Cells(SrcLast,
FoundCell.Column).Address)
If MyCell.Value = "Tribute" Then
If Rng Is Nothing Then
Set Rng = Rows(MyCell.Row & ":" &
MyCell.Row)
Else: Set Rng = Union(Rng,
Rows(MyCell.Row & ":" & MyCell.Row))
End If
End If
Next
If Not Rng Is Nothing Then
Rng.Delete
End If
Set Rng = Nothing