By using vba.booksticle.com you agree to our
cookie policy
, We and our partners operate globally and use cookies, for multiple purposes
Close
948 Steps to 6 Figures by Learning Excel-VBA and Other Skills
Step 563 - Infinite loops
Prerequisites:
Loops
What is an infinite loop?
Example:
sub infinite_loop()
i = 1
Do While i >= 1
application.statusbar = i
doevents
Loop
End Sub
How to stop them?
Use
Taskmgr
and kill Excel process
Ctrl
Shift
Esc
Break the code with
Esc
or
Ctrl
Break
How to prevent them?
When coding make sure your loops exit
Have a checklist
Have an automated check
Do code reviews and the checklist includes this
Retry code limit the number of retries
Wrap code where possible to prevent it
Global variables to prevent
Application.EnableEvents = False ' to prevent Event loop
Where do they typically happen?
Recursion without a base case
Event on spreadheet change that changes the spreadsheet
Table of Contents
|
Send us your feedback
| © 2025 All Rights Reserved |
Edit