Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I come back to my First Sub?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default How do I come back to my First Sub?

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

--
Regards,

OssieMac


"hannu" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How do I come back to my First Sub?

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
---------------
Jacob Skaria


"hannu" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How do I come back to my First Sub?

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
---------------
Jacob Skaria


"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"hannu" wrote:

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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default How do I come back to my First Sub?

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

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

"hannu" wrote in message
...
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
back ups barry Excel Discussion (Misc queries) 2 February 1st 09 07:36 PM
copy back macro/roll back moh Excel Worksheet Functions 4 March 5th 07 02:19 PM
I hid row 1 and can't get it back? Nyczoo Excel Discussion (Misc queries) 4 January 24th 06 07:22 PM
Jon - come back Wazooli Charts and Charting in Excel 0 March 24th 05 04:49 PM
Back Up Robin Clay[_3_] Excel Programming 4 August 9th 04 03:07 PM


All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"