Time Delay for Macros

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
 
G

Guest

You might try application.wait:-

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

will cause a 10 second pause.

Mike
 
G

Guest

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

Thanks

Adam Bush
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top