We are in the process of updating the site, so some pages still have the older design.
How to make a macro stop or pause for a specified amount of time.
This allows you to slow down the execution of a macro.
Add this line of code anywhere in your macro where you want it to pause.
Application.Wait(Now + TimeValue("00:00:01"))
This will pause the macro for 1 second.
The first set of zeros is hours; the second set is minutes; the third set is seconds.
Sometimes you need to pause a macro for a fraction of a second and, for this, we need to do something else.
Put this piece of code at the top of your module:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
It would look like this:

Notice that it was put above the first Sub in the module.
Then, make the macro stop or pause using this method:
Sleep(1000)

This is in milliseconds, so 1000 equals 1 second, 2000 equals 2 seconds and anything less than a thousand is a fraction of a second.

Both methods have their place; use whichever one works best for you.
Download the sample file attached to this tutorial to see these macros in Excel.
Follow along with the tutorial by downloading the files used in it. (Completely Free)
Phone number is optional - we use it to send course discounts and weekly updates via SMS.