troubleshooting Question

Has VBA been fixed so that Control Break always works?

Avatar of Robert Berke
Robert BerkeFlag for United States of America asked on
VBAMicrosoftWindows OS
19 Comments2 Solutions37 ViewsLast Modified:

Has anybody else noticed that Microsoft has finally fixed VBA so that control break always works?
And If I am wrong about it being fixed can anybody post a  snippet of an  "unbreakable" loop ?

For instance on my Windows 10 Office Pro 2010 system the following loop can now be interrupted with ctrl break. In the past, ctrl break, ctrl esc etc did not stop the loop.
Do while true
End do
 
Rberke (aka UncleBob)
 
P.S.
When I am writing complicated vba code I try to save my program about every half hour. This has avoided tons of grief when I accidentally code an "unbreakable" loop,
For most of the past 20 years, to stop such a loop I would use task manger to kill Excel. Upon restart Excel would revert to the most recent save and  I would need to spend a few minutes retyping the lost code.  
This happened so often that I eventually wrote an Unfreeze subroutine which I called at the top of almost every loop. (After my code was totally debugged I could remove the Unfreeze calls, but I often left them in place.)
For instance
For each cell in myRange.cells
Call unfreeze
if cell like desiredpattern then exit for
next
 
Sub Unfreeze
Static I
I = I + 1
If (I mod 100) = 0 then doevents
End sub


ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 19 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros