I was trying to build a count down timer using VBA, and the result can be dynamically output to an Excel cell. I let procedure abc and def recursively call each other (did not set a stop point just for testing), and it worked. However, later with this exact same code I ran again, it failed, and error message was:
Code execution has been interrupted.
Just can't figure out why, I didn't change anything, how could it work and then fail?
I tried On Error Resume Next and Application.DisplayAlert = False, both don't stop the error message popping up and the interruption of the code execution. And if I step through the procedures, it seems fine...
Also I wish to add a dynamic text like "start in how many seconds" like in the comment in another cell. Can it be realized in this way?
Thank you!
Sub abc()
[a1] = [a1] - 1
' [a2] = "Start in " & [a1] & " seconds."
Call def
End Sub
Sub def()
Application.Wait (Now + TimeValue("0:00:01"))
Call abc
End Sub
Application.Waitis holding you back since it locks everything down while it runs. This site has an interesting implementation that includesDoEventsinstead