Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Combining Modules

I have about 40 modules, and it is getting hard to figure out my code.

How can I combine them?

I have tried cutting and pasting, and then exporting and deleteing modules,
but this leads to different errors, depending on what modules combine.

Is there certain stuff in different modules?

I would have thought that if I put all of the declarations up at the top,
that I could combine them all.

Also, what is the flow when I show a form? It seems to call some
functions/subs by itself. If I try removing some of the functions, yet I
find no referance calling them in the code, I get an error on show


Thanks
Phil



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Combining Modules

Phillips,

When you Show a form the Initialize and Activate events occur.
No other events should run.

Having many (well named and well written) modules is probably better than
one with thousands of lines of spaghetti code.
***Always comment your code so you can go back and know what its doing.***
If one module calls another (and that is the only caller of the second
module) then it might be better to combine them.
To clarify: If A calls B (and nothing else calls B) then combine them.
Replace the calling line with the code from the called module.
Move only the Global declarations to the top of the combine module.

HTH
Henry

"Phillips" wrote in message
news:cFcxb.118974$Dw6.547218@attbi_s02...
I have about 40 modules, and it is getting hard to figure out my code.

How can I combine them?

I have tried cutting and pasting, and then exporting and deleteing

modules,
but this leads to different errors, depending on what modules combine.

Is there certain stuff in different modules?

I would have thought that if I put all of the declarations up at the top,
that I could combine them all.

Also, what is the flow when I show a form? It seems to call some
functions/subs by itself. If I try removing some of the functions, yet I
find no referance calling them in the code, I get an error on show


Thanks
Phil





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Combining Modules

Phil,

I would recommend that you not combine the modules. First of
all, there are limits to the size of a module: convention wisdom
holds that a module should not exceed 5000 lines of code or about
64K bytes.

Moreover, a well organized project is easier to maintain. You
should give your modules meaningful names rather leaving the
names Module1, Module2, etc. To rename a module, open it in the
VBA editor, press F4 to display the Properties box, and change
the name. Each module should contain functionally- or
conceptually-related procedures, and the module name should
reflect the contents of the module.

Also, what is the flow when I show a form?


When you show a form with code like Userform1.Show, code
execution stop at the Show method, and won't resume until the
form is hidden. Code within the form's code module will execute
in response to events, such as initializing the form, clicking a
control, etc.

If your code is executing procedures in standard code modules
randomly, you should use Rob Bovey's Code Cleaner to export all
the code to text files, purge the VBProject, and import the code
back in to the project. This can cure a variety of problems. You
can get the free Code Cleaner from the Free Utilities section at
www.appspro.com .

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Phillips" wrote in message
news:cFcxb.118974$Dw6.547218@attbi_s02...
I have about 40 modules, and it is getting hard to figure out

my code.

How can I combine them?

I have tried cutting and pasting, and then exporting and

deleteing modules,
but this leads to different errors, depending on what modules

combine.

Is there certain stuff in different modules?

I would have thought that if I put all of the declarations up

at the top,
that I could combine them all.

Also, what is the flow when I show a form? It seems to call

some
functions/subs by itself. If I try removing some of the

functions, yet I
find no referance calling them in the code, I get an error on

show


Thanks
Phil





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
VB Modules dhstein Excel Discussion (Misc queries) 9 November 8th 08 09:46 PM
Help with modules. Cloudy New Users to Excel 1 June 17th 08 10:10 AM
modules libby Excel Programming 4 November 22nd 03 01:34 PM
Class Modules vs Modules Jeff Marshall Excel Programming 2 September 28th 03 07:57 PM
Copying modules Steven Revell Excel Programming 2 September 24th 03 01:01 PM


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