LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Don't add to range if row already exists

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If a value exists in a range jeffbert Excel Programming 2 February 13th 07 01:40 PM
Check if a named range exists with VBA? [email protected] Excel Programming 3 January 31st 07 06:58 PM
See if a Range Name exists? plh Excel Programming 3 April 30th 06 10:12 PM
how to tell if a named range exists Gixxer_J_97[_2_] Excel Programming 2 June 1st 05 07:38 PM
Checking to see if a Range Object exists? debartsa Excel Programming 2 January 20th 04 06:13 PM


All times are GMT +1. The time now is 10:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"