Module Usage

helpexcel

Well-known Member
Joined
Oct 21, 2009
Messages
656
Hi - I have a general questions about whether it's best to put all your code into 1 macro, or create separate modules for each procedure and then call them? thanks!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Note that you can have multiple procedures/functions within the same module (you do not need a separate module for each procedure).

A lot of it is personal preference. I tend to not like to overwhelm my procedures and make them too big, so I like to break them up into logical chunks. It can make debugging them a little easier too.
Another reason for doing this is you can make your procedures reusable, especially if you make them generic and feed in parameters. So you can improve efficiency that way.
 
Upvote 0
As Joe said it's personal preference.
I tend to prefer all code in one procedure, with the exception of a few functions
 
Upvote 0
One of the tenants of Structured Programming is that each routine should do one thing.
So, large routines should be avoided and replaced with routines that call many different small routines when needed.

(Now I need to go see if I implied that Structured Programming is a landlord. :) )
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top