Microsoft Office Tutorials and References
In Depth Information
The Properties Window
The properties Window
The Properties window is located in the left vertical pane near the bottom of the VBE. If you
do not see the Properties window in your VBE, press F4, or from the VBE menu bar click View
Properties Window. This window displays a list of the properties and their assigned values of
whatever object is selected in the Project Explorer window. For example, in Figure 3-3, Sheet1 has
been selected and the Properties window shows you, among other details, that the Name property
for the selected object is Sheet1.
The immediate Window
The Immediate window is located at the bottom of the VBE, usually below the Code window as
depicted in Figure 3-3. If you do not see the Immediate window in your VBE, press Ctrl+G, or
from the VBE menu bar, click View Immediate Window. The name “Immediate” has nothing
to do with urgency, but rather with the notion that you can query a line of code and immediately
obtain its returned result, without having to run a macro to see what that code line does. This
comes in handy for code debugging tactics you will see in Lesson 17, but for now I just wanted to
point out the Immediate window to familiarize you with its name and location.
undErsTAnding ModulEs
I touched on modules earlier but they are worth another mention. A module is a container for your
code. A single module may hold one or many macros, depending on the workbook and your
preference for how you manage your code. For smaller projects with maybe two or three macros, just one
module is sufficient. If you develop larger projects with dozens of macros, you will want to organize
them among several modules by theme or purpose.
Several types of modules exist:
Standard Modules — These are the kind you have seen already, which hold macros you
create from scratch on your own or from the Macro Recorder.
UserForm Modules — These belong to a custom user interface object called a userform,
which is covered in Lessons 18, 19, and 20.
Class Modules — These contain the kind of VBA code that allows you to create your own
objects programmatically. Creating your own classes is very cool, and you learn about that
in Lesson 21.
Worksheet Modules — These hold VBA code that looks and acts like macros, but to
make things interesting Microsoft refers to that code as a procedure instead of as a macro.
Worksheet-level procedures are tied to various actions called “events,” such as selecting a
range or entering a value in a cell.
Workbook Module — Not to be outdone, the workbook itself has its own module, named by
default as ThisWorkbook, where code is maintained for handling workbook-level events.
The point is, several types of modules exist but the concept is the same — modules hold code for the
object(s) they serve.
Search JabSto ::

Custom Search