View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default How to Programatically Invoke "Debug"

Greg,

You can use the Stop statement. This will pause the code and bring up the
VBA Editor.

Better yet is

Debug.Assert (Condition)

where Condition is any VBA expression that returns True (or any non-zero
result) or False (or 0). If Condition is True or not equal to 0,
Debug.Assert does nothing. If Condition is False (or 0), execution will
pause on that line of code and open the VBA Editor.

The advantage of Debug.Assert is that the break is conditional -- you can
cause the code to break on Debug.Assert under only specific conditions, such
as a variable being uninitialized. Stop is not conditional. It will always
pause the code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Greg Glynn" wrote in message
oups.com...
Is there a way to halt the execution of a program or macro and invoke
debug via the code?

Regards


Greg