View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach[_5_] Otto Moehrbach[_5_] is offline
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