Microsoft Office Tutorials and References
In Depth Information
Copying Modules Between Projects
The Project Explorer provides an easy method for copying modules from one project to
another. To do so, open the source project and the destination project and then, from within
the Project Explorer window, click the module you want to copy from the source project and
drag it to the destination module. Once the mouse pointer is within the destination project,
it will change appearance from a circle with a line through it to an arrow with an outline box
and plus sign beneath it, as shown in Figure 4-11.
Figure 4-11. The mouse pointer changes to indicate a valid drop-off point when
If you copy a module into a project that already has a module of the same name, the
Visual Basic Editor will rename the module by adding a number behind the name, starting
with and incrementing each time a module of the same name is copied. Also, if there are no 1
modules of the type you’re moving, the Visual Basic Editor will create a module and the
appropriate folder to hold it.
Declaring Variables, Constants, and Data Types
Most procedures will need some type of temporary storage area to manipulate data and hold
it for later use. VBA stores this data in memory using a variable . It is also possible to store in
memory a value that is not going to change; these values are called constants . Variables can
hold values of different data types, which are specified when the variable is named, or
declared. Variables should always be declared to reduce the chance of introducing bugs in the
procedure and to properly allocate the amount of storage needed to hold the variable.