Is my Module too Big

Stephen W Allen

New Member
Joined
Jul 21, 2021
Messages
20
Office Version
  1. 2019
Platform
  1. Windows
I have created a small application in VBA, which will, eventually, be made available for general/public use. One of its modules is very large, comprising 3500 lines of code. I have been advised that this too big but have not seen any adverse effects in testing.

The module comprises 9 primary sub routines, and each of these calls its own two secondary sub routines - making 27 subs in all.
In the header there are 4 module level variables declared. These are used to process the activity of the secondary routines. It is one of the reasons for grouping such a large number of sub routines together.

What adverse effects should I look out for? How should I test for potential problems?


Stephen
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
As long as the message: "Compile Error: Procedure too large" does not appear, your code will work without problems.
If it shows the error, then you will have to divide the code into modules. If you require a variable for the module, one option is to pass it as a parameter.
 
Upvote 0
Solution
You can write-click on the module and export, then look at the size -- it should be < 64K.
 
Upvote 0
As long as the message: "Compile Error: Procedure too large" does not appear, your code will work without problems.
If it shows the error, then you will have to divide the code into modules. If you require a variable for the module, one option is to pass it as a parameter.
I confess, that is what I was hoping to hear.

You may recall that each primary routine had 2 secondaries. They are not linear. Secondary "A", which creates an array variable (sometimes two), must close, before secondary "B" can be opened. But Secondary "B" needs access to the array variable created by "A" - hence the module level variable.

Stephen
 
Upvote 0
You can write-click on the module and export, then look at the size -- it should be < 64K.
That reflects the advice that I've been given from several quarters. The message, however, seems to get muddled over the size of a module and the size of an active routine or routines.

The activity of the module is organized such that only 2 or at most 3 routines, out of the approx 30 in the module, can be active at the same time. While the overall size of the module is approx. 117K, well above your proposed limit, the active portion of the module is well below the limit.

Stephen
 
Upvote 0

Forum statistics

Threads
1,223,385
Messages
6,171,786
Members
452,424
Latest member
Sheila003

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