View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
gocush[_29_] gocush[_29_] is offline
external usenet poster
 
Posts: 252
Default why is range empty?

Bob,

If you
Set rngToFind = Nothing,

how can you then
Set rngToFind = rngToFind.Offset(-1, 0)



"Bob Phillips" wrote:

The only thing I c an see is a missing bracket

Set rngFound = Sheets("A").Columns(1).Find(rngToFind.Value)

I would also clear rngToFind as precaaution each iteration of the loop

Set rngToFind = Nothing
Set rngToFind = rngToFind.Offset(-1, 0)


--
HTH

Bob Phillips

"JT" wrote in message
...
In the code below, rngToFind is being filled correctly.
The problem is that rngFound is always empty. On sheet
("A"), there is data in column 1. Some items will match
and some won't. If the item (from sheet "P") is not found
in the rngFound (from sheet "A") then the item on
sheeet "P" should be deleted.

This is not happening. When I put my coursor over
rngFound it says empty.

Any suggestions or help would be appreciated. Thanks....

Dim rngToFind As Range
Dim rngFound As Range

Set rngToFind = Sheets("P").Range("A" & lstrowPP).End(xlUp)

Do While rngToFind.Row 1

Set rngFound = Sheets("A").Columns(1).Find rngToFind.Value)

Set rngToFind = rngToFind.Offset(-1, 0)

If Not rngFound Is Nothing Then
rngToFind.Offset(1, 0).EntireRow.Delete

End If
Loop