ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with DoEvents to show progress form, please? (https://www.excelbanter.com/excel-programming/443793-help-doevents-show-progress-form-please.html)

Ed from AZ

Help with DoEvents to show progress form, please?
 
I've got a pretty long-running macro inside a UserForm, and I wanted
to open a second form just to show that things are still working and
not crashed. It's pretty simple - four labels and I cycle around
turning one at a time a different color.

I call it from the main form with
Private Sub CommandButton1_Click()

DoEvents
frmWaiting.Show vbModeless
DoEvents

Unfortunately, once the code drops into the second form, the main code
in the first form never executes.

I thought DoEvents was supposed to let the running code "drop through"
to allow both forms to run their code. Obviously, I'm very
incorrect!! 8(

How can I make this happen correctly?
Ed

Carl Willems

Help with DoEvents to show progress form, please?
 
Hi,

this won't work that way. What you can do is put the long running code in a
separate Sub or Function and when you open the second form, have that form
call the code in the separate Sub. Inside the separate sub, you then need
to add the code to change the color in you second form.

Sounds more complicated than it actually is.

rgds,
Carl

Ed from AZ wrote in news:48ac5d93-0de6-4031-b1e4-
:

I've got a pretty long-running macro inside a UserForm, and I wanted
to open a second form just to show that things are still working and
not crashed. It's pretty simple - four labels and I cycle around
turning one at a time a different color.

I call it from the main form with
Private Sub CommandButton1_Click()

DoEvents
frmWaiting.Show vbModeless
DoEvents

Unfortunately, once the code drops into the second form, the main code
in the first form never executes.

I thought DoEvents was supposed to let the running code "drop through"
to allow both forms to run their code. Obviously, I'm very
incorrect!! 8(

How can I make this happen correctly?
Ed




All times are GMT +1. The time now is 04:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com