ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programmed pause (https://www.excelbanter.com/excel-programming/409003-programmed-pause.html)

Sam

Programmed pause
 
I have a rather long code that essentially loops through two workbooks and
copies indicated data from one to another. Everything works fine when I use a
break to view the results for each item in the loop, but I get undesirable
results when I remove the break.

How can I program a short pause (about 1 second) prior to "Next" in my loop?

Thanks,

Sam

Mike H

Programmed pause
 
My general comment would be that there is probably another underlying reason
for the error but if you must then try this

Application.Wait Now + TimeValue("00:00:1")

Gives a 1 second pause

Mike

"Sam" wrote:

I have a rather long code that essentially loops through two workbooks and
copies indicated data from one to another. Everything works fine when I use a
break to view the results for each item in the loop, but I get undesirable
results when I remove the break.

How can I program a short pause (about 1 second) prior to "Next" in my loop?

Thanks,

Sam


cht13er

Programmed pause
 
On Apr 8, 1:44*pm, Sam wrote:
I have a rather long code that essentially loops through two workbooks and
copies indicated data from one to another. Everything works fine when I use a
break to view the results for each item in the loop, but I get undesirable
results when I remove the break.

How can I program a short pause (about 1 second) prior to "Next" in my loop?

Thanks,

Sam


Dim PauseTime, StartTime

PauseTime = 1 ' Set duration (seconds)
StartTime = Timer ' Set start time.
Do While Timer < StartTime + PauseTime
'do nothing
Loop

'Continue with code


HTH

Chris


All times are GMT +1. The time now is 10:56 PM.

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