Log in

View Full Version : Solved: Sleep vs. Pause Code



m_siepel
09-28-2009, 01:51 PM
Hello..I currently have the following code that "sleeps" VBA for a certain amoutn of time:

Sleep (1500)

I am wanting to change this to pause until I click my mouse or press a key on the keyboard (preferrably the space bar). Is there a way to code this without a pop-up box? If not, what should I put in there to have the pop-up box.

Thanks

Bob Phillips
09-29-2009, 08:09 AM
This should handle Ctrl-Break



Sub WaitUntil()

On Error GoTo sleep_error
Application.EnableCancelKey = xlErrorHandler
Do

Sleep 1000
DoEvents
Loop

sleep_error:
If Err.Number = 18 Then Resume sleep_exit
sleep_exit:

End Sub