#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Skip Errors

Dear Expert,

Can I set a script at the very beginning of the macro to overrule all errors
it encounter ?

That is ... it would not halt / stop ....
Even face errors ... immediately goto next line ....

A script at the beginning to rule this ....
Just go ahead and skip the error lines and keep on running with next line.

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Skip Errors Barb Reinhardt Excel Programming 0 May 23rd 09 11:58 AM
skip to next from if John Smith Excel Programming 1 August 8th 07 06:47 AM
skip errors in an average tamiluchi Excel Worksheet Functions 8 September 25th 06 04:05 PM
Excel Throwing Circular Errors When No Errors Exist MDW Excel Worksheet Functions 1 August 10th 06 02:15 PM
Unresolved Errors in IF Statements - Errors do not show in results Markthepain Excel Worksheet Functions 2 December 3rd 04 08:49 AM


All times are GMT +1. The time now is 07:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"