Return from called Sub

Jimmy P

New Member
Joined
Aug 23, 2014
Messages
45
Been trying to find out how to return to the calling sub from a called sub and continue from the point right after the call statement.

_____________________________________
Public Sub Sub1()

code 1...

Call Sub2

code 2 ....

End Sub
_____________________________________
Public Sub Sub2()

Code....

What is procedure to return to Sub1 to code 2...

End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
After Sub2 is completed, Sub1 will continue at 'code 2...', just as you have written it; unless you have something in Sub2 that ends code execution.

Mark
 
Upvote 0
Thanks. Must have a bug in Sub2 to cause it not to return.


You can test this by putting a debug.print or a msgbox.

Code:
Public Sub Sub1()

'code 1...
MsgBox "CALLING SUB 2"
Call Sub2
MsgBox "RETURNING TO SUB 1"
'code 2 ....


End Sub




Public Sub Sub2()


'Code....


'What is procedure to return to Sub1 to code 2...
MsgBox "ENDING SUB 2"
End Sub
 
Upvote 0
You can use Code tags.

[code=rich]
'Your code between the code tags...
[/code]

Notice the solidus (slash) in the closing tag.
 
Upvote 0

Forum statistics

Threads
1,207,391
Messages
6,078,215
Members
446,321
Latest member
thecachingyeti

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