Is there a VBA Command equivalent that will act like a breakpoint? A breakpoint that doesn't disappear when the file is closed and reopened.
I have been using a message box for tthis feature during code development; but when it fires I am unable to edit either the target document or the code while the code is stopped.
Break point equivalent
-
- 5StarLounger
- Posts: 689
- Joined: 27 Jan 2010, 16:45
- Location: Ottawa, Ontario, Canada
Break point equivalent
Regards
Don
Don
-
- BronzeLounger
- Posts: 1499
- Joined: 28 Feb 2015, 13:11
- Location: Hof, Bayern, Germany
Re: Break point equivalent
Hello Don ..... easy one ....
Stop
( Stop statement )
Alan
Stop
Code: Select all
Sub StopIt() ' Break point equivalent https://eileenslounge.com/viewtopic.php?p=268543#p268543
' Doing stuff
' Doing stuff
'
Stop ' Breakpoint Command: The Stop Statement You can place Stop statements anywhere in procedures to suspend execution. Using the Stop statement is similar to setting a breakpoint in the code. The Stop statement suspends execution, but unlike End, it doesn't close any files or clear variables, unless it is in a compiled executable (.exe) file. https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/stop-statement Hi there, nice to see you here in this nice peacefull place. Hope you are well! :)
' Carry on after this from the VB Editor with a run ( F5 key ) or carry on in step mode with key F8
End Sub
Alan
I am having difficulty logging in with this account just now.
You can find me at DocAElstein also
You can find me at DocAElstein also
-
- Administrator
- Posts: 78475
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Break point equivalent
You might also like Debug.Assert. It acts like a conditional breakpoint. The syntax is
The code will continue to run as long as condition evaluates to True, but it will pause when condition evaluates to False.
Example:
When you run the Test macro, it will pause when b = 5, for then the condition b <> a is NOT true.
Code: Select all
Debug.Assert condition
Example:
Code: Select all
Sub Test()
Dim a As Long
Dim b As Long
a = 5
For b = 1 To 10
' Some code here
' ...
Debug.Assert b <> a
Next b
End Sub
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 689
- Joined: 27 Jan 2010, 16:45
- Location: Ottawa, Ontario, Canada