"End" is killing the additional code after the call.

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
I have some complex code that calls a macro then runs other code. The called macro has GoTo tags and runs correctly on its own. If I call that macro in another that has additional code in it, the "End" used to stop the other Tags in the called macro from also running, stops the new code from running after the called macro.

The code setup is like this example:

Sub myTest()
If [A1].Value = "1" Then
GoTo myRight
Else
GoTo myEnd
End If

myRight:
MsgBox "Worked"
End '<== This is the problem!

myEnd:
MsgBox "Not Right"
End Sub


Sub myRun()
myTest
MsgBox "Ran This Too!"
End Sub

What can I use inplace of "End" to stop both: myRight and myEnd from both running and run the additional code in the calling Sub myRun? Thanks Joe Was
This message was edited by Joe Was on 2002-10-26 11:38
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
I Changed the layout of the code to this:

Sub myTest()
If [A1].Value = "1" Then
GoTo myRight
Else
GoTo myEnd
End If

myRight:
MsgBox "Worked"
GoTo myKill '<== Added this in place of "End."

myEnd:
MsgBox "Not Right"

myKill: '<== And this!
End Sub

Which fixed the problem, but I would still like to know if there is a replacement for "End" other than "Stop" which will also work? JSW
 

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Thanks Steve, it worked, but now I feel like an "Idiot" for missing that! Thanks again for the second set of eyes. Joe Was
 

Forum statistics

Threads
1,144,765
Messages
5,726,161
Members
422,658
Latest member
backbeach63

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
Top