Yet another question... This time about the VBA Editor

  • Thread starter Thread starter Henry Stock
  • Start date Start date
H

Henry Stock

When I attempt to create new macros at least in between sessions in working
on my spreadsheets, it appears that the VB Editor puts the code into new
basic modules. I have modules 1 through 4 right now, but I don't seem to be
able to see them all simultaneously and there are functions I developed in
one module that I really want to use in another module. I can see them in
the object browser, but I can't seem to combine them..... I don't want to
have them all in the same physical file if I can help it.

Also I am trying to locate the actual physical file in which they are
stored. They don't seem to be stored as a .BAS file.

Can someone explain how they are being stored and what I need to do to
reference one module function inside of another module?
 
If you want to call another procedure (from module to another) you just
use:

Call ______
and fill in the blank with the name of the procedure.

Also it is relatively easy to save the modules as text files. Just
change the extension to .txt when you export it.
 
Henry

Henry said:
When I attempt to create new macros at least in between sessions in
working on my spreadsheets, it appears that the VB Editor puts the
code into new basic modules. I have modules 1 through 4 right now,
but I don't seem to be able to see them all simultaneously and there
are functions I developed in one module that I really want to use in
another module. I can see them in the object browser, but I can't
seem to combine them..... I don't want to have them all in the same
physical file if I can help it.

You can call subs and functions in other modules as easy as if they were in
the same module, unless you've used the Private keyword - then they're only
available in that module.

Code modules are not files separate from the workbook. All the code is
stored in the .xls file and modules are only there to help you organize your
code. If you really want your code to be in different physical files, then
you need multiple xls files.

To combine code from different modules, cut the code (Cntl+x) from one
module and paste it (Cntl+v) to the other. Then "Remove" the empty modules.
Also I am trying to locate the actual physical file in which they are
stored. They don't seem to be stored as a .BAS file.

There is no physical file for VBA code, it resides in the host document (xls
file for Excel VBA). You can export a code module to a bas file, but you
would only do that to back it up, clean it, or transfer it to another
workbook. The exported file has no relationship to the xls where it came
from.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top