How do I come back to my First Sub?

H

hannu

Hi. I have two subs and I want to do this:


Sub First()
1.row
Call Second
3.row
End Sub

Sub Second()
1.row
Call Third
3.row
End Sub

Sub Third()
1.row
I would like to go to First Sub right after the Call Second row, but
not to execute 3.row from the Second sub
End Sub
 
O

OssieMac

Way back when I first learnt programming it was considered best practice to
have a controlling routine and as much as possible call all subs from the
controlling routine and return to the controlling routine to call the next
sub otherwise you get what was referred to as spagetti programming.

The only reason to call another sub from a sub that has been called is to
perhaps do some data validation or similar that is required from lots of
places within the project and it should return to the calling routine and
then back to the master control routine. You should have a good reason to go
more than 2 deep in the calls.

Example:
Sub First()
1.row
Call Second
Call Third
3.row
End Sub

Sub Second()
1.row
3.row
End Sub

Sub Third()
1.row
 
J

Jacob Skaria

You should stick on to the main procedure and call Proc2 and Proc3 from Proc1
itself. Sub routines should be written only if you have a repetitive task.
For making sub procedures more flexible you can pass arguments..

If this post helps click Yes
 
J

Jacob Skaria

If you are looking to get back to 'First Sub' based on a condition then use
Exit sub before row3..

IF <condition> = True then Exit Sub

If this post helps click Yes
 
P

Patrick Molloy

Sub First()
Second()
Third()
End Sub

to be honest, I didn't get the question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top