I would like some one to show me how to set up code and a form so that when the code is running, a stop command on the form will halt the running code nicely.
i have attached an example, just to show what I mean.
when you click run, it runs some code in the background. then what needs to happen is when stop is clicked, the code is stopped nicely in a way to branch to some closing code. Userform-break-example.xls
okay, I believe you havent pressed the run button first.
the whole idea is to stop some running code.
Curt Lindstrom
Yes you're right! I didn't read your question properly :-)
Curt Lindstrom
I don't think it's possible to break the running code with a Stop button on the Userform. Your code calling the auto_open cannot even be stopped with Ctrl/break.
Try this one with two For loops. As you can see the Run button remains pressed during the execution of the code which means that no other buttons can be pressed on the form. You can however stop this code from running with Ctrl/break.
Simple indeed.
Sometimes I just have to show my ignorance to keep learning something new :-)
Thanks for the lesson Ledigimate, Sorry for misleading you thydzik.
See attached modified file
Curt