Excel Macro Problems

November 24, 2010 at 03:18:11
Specs: Windows XP
I am using Excel Macros for a simple accounting process. My top level macro calls 'Private Subprocedures' to carry out the detailed processes, and I am working with only one layer of subprocedures. The first of these subprocedures processes perfectly, goes to 'End Sub', and control returns to the main process. The second subprocedure processes perfectly until 'End Sub', at which point it does not return control to the 'parent' macro, but doggedly continues to process. Microsoft Help notes raise a caution that subprocedures can be recursive. Is there any way to force a subprocedure to close?

See More: Excel Macro Problems

November 24, 2010 at 04:49:30
re: "but doggedly continues to process"

What do you mean by continues to process?

Have you used Breakpoints and Single Step (F8) to help you determine exactly what is happening?

Have you tried Exit Sub, although I don't think you should have to force an Exit.

From the Help files:

Exit Sub
Immediately exits the Sub procedure in which it
appears. Execution continues with the statement
following the statement that called the Sub 

Since we can't see your workbook from where we're sitting, it's kind of hard to be any more specific.

Posting Tip: Before posting Data or VBA Code, read this How-To.

Report •

November 25, 2010 at 02:47:52
Thanks for your message. Yes I have singlestepped, and I have tried Exit Sub. Singlestepping shows that neither End Sub or Exit Sub takes control back to the main process. Control simply returns to the start of the subprocedure.

Report •

November 25, 2010 at 06:55:01
Well, it's a little tough to troubleshoot this from afar.

Does the offending procedure have to be a separate routine? Have you tried combining it with a routine that does return control to the main program to see if that changes anything?

If I provided an email address via private message would it be possible to send me the workbook - with any confidential information removed, of course?

Posting Tip: Before posting Data or VBA Code, read this How-To.

Report •
Related Solutions

Ask Question