When running a code that takes a long time I need to pause, do something else, and then resume the running at the place it was paused. Is this possible? How? Thank you!!
Printable View
When running a code that takes a long time I need to pause, do something else, and then resume the running at the place it was paused. Is this possible? How? Thank you!!
Yes, its possible in many different ways.
VB Code:
'5 second pause Dim tmr As Single Dim sec As Integer sec = 5 tmr = Timer While Timer < tmr + sec DoEvents WendVB Code:
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long) Public Sub Workbook_Open() Sleep 5000 'Implements a 5 second delay End Sub
Alternatly, using 'DoEvents' will yeild the processor to other tasks within the app, like enabling the pressing of a CommandButton during say a Do - Loop.
Bruce.
But the posted stated that they wanted to pause, do something
else, then continue on. Thats why I gave two examples. One to
do what they asked and another to just stop and then continue.
:D