View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Myrna Larson Myrna Larson is offline
external usenet poster
 
Posts: 863
Default killing all procedures?

True, but not considered "good programming practice" by the purists, and it
has the drawback you note re open files, etc.

On 4 Oct 2005 15:41:24 -0700, "Walt" wrote:

Hi Ouka,

From the Excel VBA Help system:

Statement: End
Description: Terminates execution immediately. Never required by
itself but may be placed anywhere in a procedure to end code execution,
close files opened with the Open statement and to clear variables.

Meaning this should do it:
Private SubP1()
On Error Goto Handler1
'sub procedure code here'
Exit Sub
Handler1:
MsbBox "An error has occurred, exiting procedure"
'EXIT code here, if any, besides the following End statement'
End <<<<<<<<< This shuts down VBA execution at this point
End Sub

NOTE: The closing of VBA opened files and clearing of variables may
require accommodation in your program flow.

Best Regards,
Walt