Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

I want to trap an error I get in a macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mary - 31 Mar 2006 22:33 GMT
Hello,

I am trying to show some values using msgbox after using FIND. But when I
try to find a value that does not exist in the sheet I get an error:
Run_time: "91"

h = InputBox("Type number of holes to find")
       
   For X = 1 To h
   
   np = InputBox("type the name of the hole:")
   
    Cells.Find(What:=np, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
       :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
       False, SearchFormat:=False).Activate
       
       N = ActiveCell
       L = ActiveCell.Offset(0, 1)
       S = ActiveCell.Offset(0, 2)
                     
       MsgBox ("Pozo:" & " " & N & " " & "Linea:" & " " & L & " " &
"Serial:" & " " & S)
       
       End If
       
       Next
       
How can I trap this run-time error?

Thanks
lcifers - 31 Mar 2006 22:43 GMT
Mary,

You should google "On Error Resume Next" and "On Error GoTo". I think
this is what you're looking for.

Regards,

> Hello,
>
[quoted text clipped - 27 lines]
>
> Thanks
Bob Phillips - 31 Mar 2006 22:45 GMT
   h = InputBox("Type number of holes to find")

   For X = 1 To h

       np = InputBox("type the name of the hole:")

       Set Cell = Cells.Find(What:=np, _
                            After:=ActiveCell, _
                            LookIn:=xlFormulas, _
                            LookAt:=xlPart, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False, _
                            SearchFormat:=False)
       If Not Cell Is Nothing Then
           N = Cell.Value
           L = Cell.Offset(0, 1).Value
           S = Cell.Offset(0, 2).Value

           MsgBox ("Pozo:" & " " & N & " " & "Linea:" & _
                   " " & L & " " & "Serial:" & " " & S)
       End If

   Next

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

> Hello,
>
[quoted text clipped - 27 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.