Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cancel a Procedure through a Userform


hi guys

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

thanks in advanc

--
jumpjum
-----------------------------------------------------------------------
jumpjump's Profile: http://www.excelforum.com/member.php...fo&userid=2656
View this thread: http://www.excelforum.com/showthread.php?threadid=40031

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in
message ...

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get userform Cancel button to invoke Exit Sub in calling macro? Craig Remillard New Users to Excel 1 November 19th 09 03:55 AM
userform output to procedure shellshock Excel Programming 2 July 29th 05 11:31 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Cancel Button on Userform KJ Dahl Excel Programming 2 December 19th 04 07:47 PM
Call Sub Procedure object_Exit(ByVal Cancel As MSForms.ReturnBoole Kevin McCartney Excel Programming 1 October 8th 04 10:37 AM


All times are GMT +1. The time now is 10:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"