find failure stops macro with run time error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Subject: macro search error stopped macro run
From: "mel.krom" <[email protected]> Sent:
5/7/2004 4:25:38 AM




This appears to great great for repeat searches on for the
boardVT value, but fails and stops the macro with run-time
error 91 when no match is found. How can I correct or
handle error.

Range("K" & foundRAL, "K" & foundRAH).Select
Dim asisfind
BoardlocVT = Trim(BoardlocV) & ","
asisfind = Selection.Find(What:=BoardlocVT,
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

Thanks
 
One way:

Dim asisfind as string
Dim rFound As Range
BoardlocVT = Trim(BoardlocV) & ","
On Error Resume next
Set rFound = Range("K" & foundRAL, "K" & found.Rah).Find( _
What:=BoardlocVT, _
After:=Range("K" & foundRAL), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
MatchCase:=False)
On Error GoTo 0
If rFound Is Nothing Then _
Msgbox "Not found
 
Back
Top