Thread: Skip Errors
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
royUK[_122_] royUK[_122_] is offline
external usenet poster
 
Posts: 1
Default Skip Errors


You can do that like this

Code:
--------------------

Option Explicit

Sub x()
On Error Resume Next
'code
On Error GoTo 0
End Sub

--------------------


However just instructing Excel to ignore errors is a bad idea, you
should fix the errors in your code.

Also, remember that if you add an error habdler like this whilst
developing the code then you will not be able to pinpoint any errors in
your code. Error handlers should be added after the code is working
correctly.

You can use this type of error handler to return a messagebox with
details of the error

Code:
--------------------

Option Explicit

Sub testmacro()

On Error GoTo testmacro_Error
'REPLCE WITH your code
Rows(Rows.Count + 1).Select
On Error GoTo 0
Exit Sub

testmacro_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure testmacro of Module Module1"
End Sub
--------------------


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=99814