Thread: VB Modules
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
ShaneDevenshire ShaneDevenshire is offline
external usenet poster
 
Posts: 2,344
Default VB Modules

Hi,

1. Everytime you close your workbook and then reopen and record a new macro,
Excel begins a new Module. If you record your modules all during one session
(while the workbook stays open) Excel records all the code into the same
module. But again, not so if you close the file and reopen and begin a new
recording.

2. Excel uniquely names each module just like sheets in a workbook.

3. You can delete any module by right clicking it and choose Remove....

4. You can copy code from one module to another even in another workbook

5. You can, and should, rename your modules. You can do that if the
Properties window is displayed and you are on a module in the Projects
window. The first property is Name (no spaces allowed in names)

6. You can refer to a module in code if necessary, for example if you have
two workbooks open and you want to execute the code in a module with the same
name as one in the active workbook, but in the other workbook. But this is
getting a little far into the VBA area.

--
Thanks,
Shane Devenshire


"dhstein" wrote:

I'm trying to understand the Naming/Use of Modules in VB. I have several
Excel workbooks with VB macros that I've either developed or copied from the
web. At the moment, I have only one workbook open and I see in the VB
Project window that I have 9 modules - some of which are completely empty.
Does Excel keep track of modules and name each one uniquely? What happens if
I copy the code from module 9 into module 1 and another workbook has module 1
defined? Any help would be appreciated. Thanks.