Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2009, 05:39 PM
Authorized User
 
Join Date: Sep 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to stop running a macro when a userform is closed

Hello,
I have a macro that begins by using userforms to get data from the user.
I want to make it so that the whole macro stops running (similar to using the pause/break button on the keyboard but without errors) if one of the userforms is closed (using the red x), but i can only seem to get it to stop the specific function it's in.....
 
Old September 28th, 2009, 09:15 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Can you try the following:

Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    End
End Sub
This will terminate the entire program. If you are using many objects in memory it will be better to redirect the program to a function that releases the objects and eventually 'End's the program

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old September 29th, 2009, 02:37 PM
Authorized User
 
Join Date: Sep 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks, Shasur

I ended up having to change it a bit, but it works now :)
I can't believe I couldn't find the simple end command anywhere online!!!


Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = 0 Then
        End
    End If
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Apps keep running after stop Ron Howerton Visual Studio 2005 1 April 11th, 2008 12:15 AM
Probs while running macro anukagni Excel VBA 2 February 2nd, 2006 03:29 AM
stop macro from running on EVERY cell change!! forkliftpete Beginning VB 6 1 October 26th, 2005 07:36 AM
Show Sheet after running macro sridevi Excel VBA 2 November 5th, 2004 08:18 AM
DTS Running Until Non Stop Jane SQL Server DTS 2 February 29th, 2004 05:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.