Time Delay for Macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know how to introduce a time delay into VBA macros? I created a
macro that runs an application on about 15 different worksheets. I want to
be able to have the macro pause between worksheets, to allow this application
to have enough time to download on every sheet. Is this possible? If so,
what code would I need?

Thanks

Adam Bush
 
You might try application.wait:-

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

will cause a 10 second pause.

Mike
 
Thanks for your help Mike. It worked perfectly. I was wondering if you
could do partial seconds.

Thanks

Adam Bush
 
Here is one that can be put into the standard module as a public declaration
at the top of the module and called at anytime by simply typing:

HalfSecDly

on a line by itself in your code.

Public Function HalfSecDly()
y = Timer + 0.5
Do While Timer < y
DoEvents
Loop
End Function

You can create other functions for different time delays by changing the 0.5
to another number. i.e. 0.1 = tenth second, 1 = one second 10 = 10 seconds,
etc.
There is a way to set it up for microseconds but I find tenths to be good
enough.
 
Back
Top