ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pause code, wait for input, no input received, carry on with the code (https://www.excelbanter.com/excel-programming/341433-pause-code-wait-input-no-input-received-carry-code.html)

[email protected]

Pause code, wait for input, no input received, carry on with the code
 
I am trying to schedule reports to rn in excel using the open event,
but obviously might need to change the code, so when I run it I want it
to pop a box and ask if it should run and give me 10-20 seconds to
click no so I can amend the code.

The idea is the workbook opens, pops a box asking if its OK to run with
a count down preferably, run the code if it receives no input.

I know about mode/modeless userforms and have tried using the "wait"
command, but that doesnt let you stop the code using the button.

Is there a do loop or a for next I can use and update a label on a form
to tell me how long I have. Quite new to this.

Any ideas gratefully received.

Thanks john


[email protected]

Pause code, wait for input, no input received, carry on with the code
 
Figured it out, just in case someone else needs it.

Sub testwait()

UserForm1.Show vbModeless

TimedDelay 9

MsgBox "wait over"

End Sub


Sub TimedDelay(sec As Single)
Dim x As long
x = Timer + sec

Do While Timer < x
nSec = Round(x - Timer, 0)
UserForm1.Label3 = nSec
DoEvents
Loop
End Sub

Thanks John



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

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