Consulting

Results 1 to 2 of 2

Thread: Solved: Sleep vs. Pause Code

  1. #1
    VBAX Newbie
    Joined
    Sep 2009
    Posts
    2
    Location

    Solved: Sleep vs. Pause Code

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    This should handle Ctrl-Break

    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •