View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default Trap a find error

strSearchColumn = "I:I"
strTarget = "0"
Set rngFind = Range(strSearchColumn).Find(strTarget,
SearchDirection:=xlPrevious)
If rngFind Is Nothing Then
MsgBox "Not Found"
Else
strLastDeleteRow = rngFind.Row
End If

HTH
"quartz" wrote:

I have the following code. How can I most efficiently exit the function if no
target string is found?

strSearchColumn = "I:I"
strTarget = "0"
Set rngFind = Range(strSearchColumn).Find(strTarget,
SearchDirection:=xlPrevious)
strLastDeleteRow = rngFind.Row

Thanks in advance.