Microsoft Office Tutorials and References
In Depth Information
At any given time, the VB Editor may have lots of code windows. Code windows
are much like worksheet windows in Excel. You can minimize them, maximize
them, hide them, rearrange them, and so on. Most people find that it’s much easier
to maximize the code window that they’re working on. Sometimes, however, you
may want to have two or more code windows visible. For example, you may want
to compare the code in two modules, or copy code from one module to another.
Minimizing a code window gets it out of the way. You also can click the Close
button in a code window’s title bar to close the window completely. To open it
again, just double-click the appropriate object in the Project window.
You can’t close a workbook from the VB Editor. You must reactivate Excel and
close it from there.
In general, a module can hold three types of code:
Sub procedures: A procedure is a set of instructions that performs some
action. For example, you may have a Sub procedure that combines
various parts of a workbook into a concise report.
Function procedures: A function is a set of instructions that returns a
single value or an array. You can use Function procedures in worksheet
Declarations: A declaration is information about a variable that you
provide to VBA. For example, you can declare the data type for variables that
you plan to use.
A single VBA module can store any number of procedures and declarations.
Entering VBA code
This section describes the various ways of entering VBA code in a code window. For
Function procedures, the code window will always be a VBA module. You can add
code to a VBA module in three ways:
Use your keyboard to type it.
Use Excel’s macro-recorder feature to record your actions and convert
them into VBA code.
Copy the code from another module and paste it into the module that you
are working on.
Search JabSto ::

Custom Search