Thread: If Error
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chris Putzig Chris Putzig is offline
external usenet poster
 
Posts: 5
Default If Error

Try this:

On Error Resume Next 'disable error
myRow = Worksheets("Blank 1").Rows.Find _
(What:=AgentName).Row + 1
If myRow 0 Then
'do something
MsgBox myRow
Else
MsgBox AgentName & " not found"
End If
On Error GoTo 0 'reset error

"Mike" wrote in message
...
Hi.

The following code finds a text string in
worksheet "Blank 1". I need to have a msgbox come-up if
the text is not found. How should I program so that an
error won't throw the user into the module?

myRow = Worksheets("Blank 1").Rows.Find
(What:=AgentName).Row + 1

Thanks,
Mike.