View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default How to deal with Find when nothing is found

hi
dim findnotfind as range
set findnotfind = Cells.Find(what:=LOC, After:=ActiveCell, LookIn:=xlValues,
LookAt:=xlPart,
SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
if findnotfind is nothing then
msgbox "I'm sorry the value was not found"
exit sub
end if


"Mike" wrote:

I have this in my Sub.

Cells.Find(what:=LOC, After:=ActiveCell, LookIn:=xlValues, LookAt:=xlPart,
SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate

If the string is not found, it runs an error, giving the user the option to
debug. How can I have it comeback and say the string was not found and then
end the sub? Am I making sense? Thanks.