Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default many subs or many modules


Is it best to program many subs and functions into one module or one sub
per module resulting many modules? What are the pro and cons using, or
efficiency in either of these methods.
Thanks,


--
webby2006
------------------------------------------------------------------------
webby2006's Profile: http://www.excelforum.com/member.php...o&userid=36744
View this thread: http://www.excelforum.com/showthread...hreadid=567498

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default many subs or many modules

While I have not had any classes in programming, I keep one module,
mdlFunctions, with the functions that I will use frequently, then one
other, mdlMain, module with the main program. If I have more that one
program in a project I create a separate module for each program. My
mdlFunctions is easily available to both routines and when I later go
back to look for those functions it's easier to find them than if I had
to search through all the "Main" modules. Another advantage of my
mdlFunctions is that on starting a new project, I can simply import
mdlFunctions and have a good start for what I usually need to do.

Charles
xl Geek
webby2006 wrote:
Is it best to program many subs and functions into one module or one sub
per module resulting many modules? What are the pro and cons using, or
efficiency in either of these methods.
Thanks,


--
webby2006
------------------------------------------------------------------------
webby2006's Profile: http://www.excelforum.com/member.php...o&userid=36744
View this thread: http://www.excelforum.com/showthread...hreadid=567498


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default many subs or many modules

There are no hard and fast rules here but the idea is to try to keep things
organized as best you can. Sometimes these things get to be very large and it
is not efficient to have everything in one module any more that it is
efficient to have many, many modules. The best practice is to organize
similar subs and functions together into modules that you have named. For
instance I will often have a module called modProtection where I keep all of
my protection and security procedures. I will have another module called
modFormatting where I keep all of my procedures that deal with reformatting
sheets. By grouping similar functionallity together it makes the program
easier to debug. When something goes wrong I know where to look.
--
HTH...

Jim Thomlinson


"webby2006" wrote:


Is it best to program many subs and functions into one module or one sub
per module resulting many modules? What are the pro and cons using, or
efficiency in either of these methods.
Thanks,


--
webby2006
------------------------------------------------------------------------
webby2006's Profile: http://www.excelforum.com/member.php...o&userid=36744
View this thread: http://www.excelforum.com/showthread...hreadid=567498


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default many subs or many modules

Although I am not a professional programmer I have been using VBA in Excel
for years. I originally put one or two subs in a module. Sounded good at
the time but when I later went back to edit a sub I had a difficult time
remembering what module it was in. I currently have all my subs that are
related to a particular spreadsheet in one modules. Editing is much simpler
now because I can go up to the drop down box that lists all of my
subroutines, select the one I want to work on and it takes me right to it.

I agree with the others that have indicated orgination is the key. So it
basically boils down to whatever works best for you. For me one module with
many subs fits best in daily practices. If I get to the point where I have a
multitude of subs in a single module, I will probably do as someone else
stated and separate subs with like functions into various modules. Haven't
reached that point yet!

Jeff Boyle
Isothermal Community College


"webby2006" wrote:


Is it best to program many subs and functions into one module or one sub
per module resulting many modules? What are the pro and cons using, or
efficiency in either of these methods.
Thanks,


--
webby2006
------------------------------------------------------------------------
webby2006's Profile:
http://www.excelforum.com/member.php...o&userid=36744
View this thread: http://www.excelforum.com/showthread...hreadid=567498


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default many subs or many modules

webby2006 wrote:
Is it best to program many subs and functions into one module or one sub
per module resulting many modules? What are the pro and cons using, or
efficiency in either of these methods.
Thanks,


Keep functions somehow connect to each other in one module.
Create as many modules as you need to keep structure of entire project
clear.

Read this
http://www.answers.com/topic/cohesion-computer-science



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default many subs or many modules


Thank you for all your replies.

I am glad I have not strayed too far from logically grouping similar
routines into the one module like Jim has mentioned. i.e. all
formatting in one module and files manipulation in another.

Many many thanks.


--
webby2006
------------------------------------------------------------------------
webby2006's Profile: http://www.excelforum.com/member.php...o&userid=36744
View this thread: http://www.excelforum.com/showthread...hreadid=567498

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
Public, Private, Event modules, Forms modules,,, Jim May Excel Programming 11 October 31st 05 03:12 AM
ending subs [email protected] Excel Programming 2 May 17th 05 06:13 PM
Basic question - modules and class modules - what's the difference? Mark Stephens[_3_] Excel Programming 9 May 8th 05 11:48 AM
When to code in sheet or userform modules and when to use modules Tony James Excel Programming 1 December 16th 04 10:02 PM
Class Modules vs Modules Jeff Marshall Excel Programming 2 September 28th 03 07:57 PM


All times are GMT +1. The time now is 07:04 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"