Greg,
You can use either
Stop
Debug.Assert False
'Or some condition like
Debug.Assert MyBoolean
As these are in code, they remain between close/open of the file.
Setting break points (left click, level with an executable line of code) on
the left border of the code pane, so you get the line highlighted (the
default colour being red).
Breakpoints a removed when the file is closed.
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)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.