+ Reply to Thread
Results 1 to 2 of 2

Cancel a Procedure through a Userform

  1. #1
    Registered User
    Join Date
    08-23-2005
    Posts
    4

    Exclamation Exit a Procedure through a Userform

    hi guys

    I want to exit my procedure(which is at that point within a loop) when I press the cancel button on my user form.
    Is there a predefined command which will execute the action? Or do I have to write a code for that.
    Please let me know if u have an answer

    thanks in advance
    Last edited by jumpjump; 08-29-2005 at 11:30 PM.

  2. #2
    Bob Phillips
    Guest

    Re: Cancel a Procedure through a Userform

    If you want to cancel running code, then you need to give the cancel button
    a look in. This can be done by issuing DoEvents intermittently in the
    running procedure.

    Here is a simple example, two buttons on the form, one to start the code,
    one to cancel.

    Private Sub CommandButton1_Click()
    Dim i As Long
    For i = 1 To 1000000
    Application.StatusBar = "Processing " & i
    DoEvents
    Next i

    End Sub

    Private Sub CommandButton2_Click()
    Unload Me
    End
    End Sub


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "jumpjump" <[email protected]> wrote in
    message news:[email protected]...
    >
    > hi guys
    >
    > I want to exit my procedure(which is at that point within a loop) when
    > I press the cancel button on my user form.
    > Is there a predefined command which will execute the action? Or do I
    > have to write a code for that.
    > Please let me know if u have an answer
    >
    > thanks in advance
    >
    >
    > --
    > jumpjump
    > ------------------------------------------------------------------------
    > jumpjump's Profile:

    http://www.excelforum.com/member.php...o&userid=26568
    > View this thread: http://www.excelforum.com/showthread...hreadid=400316
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1