View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default using find method after using it earlier

I can't see you code, but it could be that you don't set all the options or
you could be searching after the activecell and that isn't located where you
think.

Sub SubFindIt()
sStr = "ABC"
Set rng = Cells.Find(What:=sStr, _
After:=Range("IV65536"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
MsgBox sStr & " found at " & rng.Address
Else
MsgBox sStr & " not found"
End If
End Sub

would be a good way to do the search. Obviously, consult the help on find
and adjust the arguments to meet your needs.

Also, I assume you are using Find and not FindNext. You wouldn't want to
use findnext if you are changing what you are searching for.

--
Regards,
Tom Ogilvy



"rub" wrote in message
ups.com...
I use the find method to find a cell. I copy the contents of the
cells. Later I use the find method to find a different string. At
this point it find the first string or sometimes gives me an error that
object not found. Any ideas. Is there a way to clear a register hold
the first string?