MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Is this possible

Posted by Frank on December 22, 2001 5:12 PM


Is there a way to call another sub() and goto a label within that sub to start.

For example

call mysub c:

would go to mysub then c: then start compiling.

Just wondering.


Posted by Ivan F Moala on December 22, 2001 8:37 PM

One way todo this is as follows;
Note: A bit of thought has to go into the
routine to get the structure/Flow you want
right. There are other ways but this should
get you going quickly.

Sub Original()
'some code

Call calling(2)

'some more code

End Sub

Sub calling(Where As Integer)
Select Case Where

Case 1
GoTo 1
Case 2
GoTo 2
Case 3
GoTo 3
End Select

MsgBox Where

Exit Sub
MsgBox Where

Exit Sub
MsgBox Where

End Sub