Archive of Mr Excel Message Board


Back to Excel VBA archive index
Back to archive home

Create a pause within a macro

Posted by Stuart on October 09, 2001 7:26 AM
Is there any way to create a pause in a macro? I want the macro to wait 5 seconds between two functions, but am unsure how to do it.

Any help appreciated.


Check out our Excel VBA Resources

Re: Create a pause within a macro

Posted by Mark O'Brien on October 09, 2001 7:39 AM


Private Sub SetPause()
Dim newHour, newMinute, newSecond, waitTime
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
End Sub


Re: Create a pause within a macro

Posted by Tom Morales on October 09, 2001 10:02 AM
Stuart - Add the following line to your code, at the appropriate juncture:

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

Tom


Thanks guys.

Posted by Stuart on October 10, 2001 8:01 PM


This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.