Closing one sub from another

Gkruithoff

New Member
Joined
Jun 2, 2011
Messages
4
Hi all,

I'm trying to create a button on a Userform that will not only close the userform (that part I've got down) but also end the subroutine running behind the Userform.

There is a subroutine that calls the Userform that keeps running after the Userform is unloaded or hidden and I want the button on the User form to end the subroutine that calls the Userform

Essentially I'm just trying to figure out how to close or end one sub from another sub and I can't find the right commands

Any help?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
To terminate all processes try the End command.
 
Upvote 0
Hi Glenn,

thanks for the response - but no, unless you could show me how it is used, I've tried everything in regard to the End command but with no luck. Essentially I've tried:

Worksheets("Index").CommandButton1.End

and many variations thereof.

I'm trying to do this:

Sub EndingAnotherSub()

Worksheets("Index").CommandButton1.End
Unload Userform1

End Sub

but the CommandButton1 sub on the Index worksheet doesn't end or quit - not only does that line produce an error but the CommandButton sub continues to run in the back ground even after the Userform1 is stopped.

I want the procedures of CommandButton1 subroutine to end when called to end from another sub.
 
Upvote 0
Like this:
Code:
Sub EndingAnotherSub()

End
' there's no point in putting any code after an End, is there ! ...Unload Userform1

End Sub
 
Upvote 0
Sorry Glenn,

By placing and 'end' at that point of the sub, won't it just end the current sub - I'm wanting it to end another sub attached to a different worksheet
 
Upvote 0
Sorry Glenn,

By placing and 'end' at that point of the sub, won't it just end the current sub - I'm wanting it to end another sub attached to a different worksheet
Have you actually tried it?
 
Upvote 0
Hi Glenn,

sorry for the delayed response...I completely bow to your excel vba brilliance...I was completely over thinking that solution.

Thanks so much again
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,825
Members
449,470
Latest member
Subhash Chand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top