LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default When To use GOTO Sub?

Depends. It is particularly useful to set up a separate sub that can be
called by other subs if those other subs need to perform similar functions.
If you have to ever make changes to the code, it is easier because you only
have to do it once.

For example, I have one template that has to perform a dozen or so different
filter operations on a particular table. Instead of writing 12 filter
procedures, I have one sub that actually performs the filtering. The other
12 pass parameters to it (filter criteria, etc) and perform any other
procedures/setup that is specific to their own filter operation (one filter
operation has to get user input, so it does that and passes the info along to
the filter sub - but getting user input is specific only to that particular
filter operation).

I usually go with what appears organized and logical to me. Using
additional subs can also help w/testing and debugging. You can set up some
dummy data and a test macro that calls the sub you want to test/debug and
step through it without having to run/step through one giant macro in order
to test/debug only one particular part of it. OTOH I avoid setting up
another sub when it would require too much duplicate work, or a lot of
parameter passing, or require most of my variables to be declared at the
module level.



"MC82" wrote:


Thanks for the explanation guys. What about the usage of "Call" Sub?
Is this also something I should refrain from using much?


--
MC82
------------------------------------------------------------------------
MC82's Profile: http://www.excelforum.com/member.php...o&userid=18682
View this thread: http://www.excelforum.com/showthread...hreadid=540083




 
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
? IF & GOTO ? Karen D Excel Worksheet Functions 17 September 2nd 09 10:58 PM
If.....Then GoTo....... Alec H Excel Discussion (Misc queries) 4 February 22nd 06 02:42 PM
On Error Goto doesn't goto Paul Excel Programming 1 October 15th 04 03:51 PM
On Error Goto doesn't goto Paul Excel Programming 0 October 15th 04 03:05 PM
Goto next used row JonWayn Excel Programming 0 November 20th 03 03:00 AM


All times are GMT +1. The time now is 10:37 AM.

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

About Us

"It's about Microsoft Excel"