ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Yet another question... This time about the VBA Editor (https://www.excelbanter.com/excel-programming/323885-yet-another-question-time-about-vba-editor.html)

Henry Stock

Yet another question... This time about the VBA Editor
 
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?

--
Henry Stock, Network Administrator
onProject.com
3 Wing Drive
Cedar Knolls, NJ 07927-1006



Chip[_3_]

Yet another question... This time about the VBA Editor
 
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.


Dick Kusleika[_4_]

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

Henry Stock wrote:
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.


Can someone explain how they are being stored and what I need to do to
reference one module function inside of another module?

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com




All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com