Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default General question re Error Handling

hello experts

This is just a general question for my own education. I've dabbled in a
fair amount of Access VBA in the past, but have just started learning about
Excel VBA. In Access, we would use Error Handling in almost every sub, but
In Excel, error Handling seems to be the exception rather than the rule. I
can't even find much about it in the Excel VBA help, and there are relatively
few references to it in this forum. What gives?

Just Curious
Terry W.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default General question re Error Handling

Terry, I use it all the time. My favorite approach is:

Public Const bDebug as boolean = true or false (depending on need)

Sub Main_Routine_With_Error_Trap()
if not bdebug then on error goto etrap
Main_Procedure
exit sub
etrap:
msgbox "Woops " & err.desription
End Sub

The above, with a better message obviously, traps all errors except those
in procedures in user forms. I thus tend to not run any elaborate user form
code other than input validation.

If I'm debugging code, I set bDebug to True. When I'm done, I set to False.
And, I put a If statement in the auto_close to warn me if bDebug is true.

Some use of On Error Resume Next to avoid errors and then testing the result
to see what actually happened. For example

Dim wB as workbook
set wB = Nothing
On error resume next
set wB = workbooks("My workbook.xls")
on error goto 0
if wb is nothing then msgbox "My workbook.xls is not open"

Robert Flanagan
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel



"terry w" wrote in message
...
hello experts

This is just a general question for my own education. I've dabbled in a
fair amount of Access VBA in the past, but have just started learning
about
Excel VBA. In Access, we would use Error Handling in almost every sub,
but
In Excel, error Handling seems to be the exception rather than the rule.
I
can't even find much about it in the Excel VBA help, and there are
relatively
few references to it in this forum. What gives?

Just Curious
Terry W.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default General question re Error Handling

Chip Pearson shares a lot of notes:
http://www.cpearson.com/excel/ErrorHandling.htm



terry w wrote:

hello experts

This is just a general question for my own education. I've dabbled in a
fair amount of Access VBA in the past, but have just started learning about
Excel VBA. In Access, we would use Error Handling in almost every sub, but
In Excel, error Handling seems to be the exception rather than the rule. I
can't even find much about it in the Excel VBA help, and there are relatively
few references to it in this forum. What gives?

Just Curious
Terry W.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default General question re Error Handling

Thanks Robert and Dave. This was quite helpful.
Terry W.


"Dave Peterson" wrote:

Chip Pearson shares a lot of notes:
http://www.cpearson.com/excel/ErrorHandling.htm



terry w wrote:

hello experts

This is just a general question for my own education. I've dabbled in a
fair amount of Access VBA in the past, but have just started learning about
Excel VBA. In Access, we would use Error Handling in almost every sub, but
In Excel, error Handling seems to be the exception rather than the rule. I
can't even find much about it in the Excel VBA help, and there are relatively
few references to it in this forum. What gives?

Just Curious
Terry W.


--

Dave Peterson
.

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
Another Error Handling Question brichard429 Excel Programming 4 November 27th 09 03:58 PM
ERROR HANDLING question Brettjg Excel Programming 0 March 9th 09 01:51 AM
error handling question ADK Excel Programming 13 July 17th 07 04:00 PM
Error handling question colofnature[_56_] Excel Programming 0 June 6th 06 05:38 PM
question error handling Pierre via OfficeKB.com[_2_] Excel Programming 3 November 7th 05 09:39 PM


All times are GMT +1. The time now is 06:59 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"