PDA

View Full Version : display a "Please Wait" box while calculating



dlh
10-30-2008, 09:30 AM
I must be missing something simple... How do I show a generic userform (captioned "please wait while I calculate this") before I begin calculation and then unload it when calculation is finished. The problem is the userform takes focus and my calculation won't start until I close the form. I'm trying to avoid putting the calculation code *in* the userform, because then I'd have to have a different form each instance I need this.

Multithreading is new to me. Many thanks for any advice.

jfournier
10-30-2008, 09:49 AM
I call the show method of the form with 0 as a parameter, making it modeless (I believe) so it'll show the form and then your macro will keep running, then you can just unload/hide the form once you're done calculating

dlh
10-30-2008, 10:01 AM
Thank you, jfournier. Almost works. The code now runs, but the interior of the userform window is never drawn.


PopupWait.Show (0)

jfournier
10-30-2008, 10:07 AM
you may need to call DoEvents during your code to get the form to update. I usually do this at the beginning or end of a loop. Using DoEvents allows you to process userform control events, like hitting a cancel button, to stop your processing...

dlh
10-30-2008, 10:22 AM
Thank you very much. It works as intended.

Am I correct in understanding that if I have set Application.EnableEvents to FALSE, then DoEvents will only allow predefined application events to run, not user-defined events like Worksheet_Change?