Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default On Error Resume Next

I have seen "On Error Resume Next" in several different
macros but do not fully understand how it works. Any help
would be greatly appreciated. Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default On Error Resume Next

AFAIK it means what it says. If you encounter something that would cause an
error to stop your code, just ignore it and go on to the next thing which
may work. This may be good but it might ignore something you need to know
about.

--
Don Guillett
SalesAid Software

"Mike" wrote in message
...
I have seen "On Error Resume Next" in several different
macros but do not fully understand how it works. Any help
would be greatly appreciated. Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default On Error Resume Next

If a line of code is encountered that causes an error, "On Error Resume
Next" will not process that line of code but will resume execution on the
following line.

"On Error Resume Next" is quite handy if you want to handle errors "in-line"
rather than running a sub and ending the procedu


On Error Resume Next
'Some line of code that returns an error here
If err.number = ErrorCodeToCheckFor then
'Do some stuff to handle the error
err.clear


--
Michael Hopwood (Phobos)


"Mike" wrote in message
...
I have seen "On Error Resume Next" in several different
macros but do not fully understand how it works. Any help
would be greatly appreciated. Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default On Error Resume Next

Mike
Don and Michael gave you good info on what it does. I just want to add
one point.
Be aware that the instruction "On Error Resume Next" remains in force
until the end (End Sub or Exit Sub) of the current procedure. This is of no
consequence to you if the procedure consists of only the line that you
anticipated an error on. But if you have other things happening in the code
besides the one line that you thought might cause an error, you can have a
problem. If an error were to occur later but still in the same procedure,
Excel would simply "Resume Next". Then you would run around chasing your
tail trying to figure out why the data is not what you expected. Been
there.
You should always reinstate Excel's normal error procedures immediately
after the line that could cause the error. For example:
Sub MyMacro()
'Some code
On Error Resume Next
'The line that might cause an error
On Error GoTo 0
'More code
End Sub

The "On Error GoTo 0" returns error handling back to normal or default. HTH
Otto
"Mike" wrote in message
...
I have seen "On Error Resume Next" in several different
macros but do not fully understand how it works. Any help
would be greatly appreciated. Thanks



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
On error resume next not working cluckers Excel Discussion (Misc queries) 3 November 25th 09 08:12 PM
Autofill & On Error Resume Next Dandelo Excel Discussion (Misc queries) 2 August 21st 08 07:14 PM
On Error Resume Next problem Jim May Excel Discussion (Misc queries) 14 November 2nd 07 12:27 PM
On error resume next problem freekrill Excel Discussion (Misc queries) 2 December 7th 05 12:51 AM


All times are GMT +1. The time now is 11:26 PM.

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

About Us

"It's about Microsoft Excel"