Microsoft Office Tutorials and References
In Depth Information
Managing Code Windows
Keeping code organized and easy to find is just as important within an Excel project as keep­
ing the files located on your hard drive organized. Fortunately, the Visual Basic Editor Project
Explorer presents the elements of a project in the same tree view that is used by Windows
Explorer. The Project Explorer is not as flexible as Windows Explorer, but it does keep similar
elements of a project grouped together within a common folder. This familiar organization
makes it easier to find a particular module, class module, user form, or other Excel object
when needed.
Handling Windows
Each individual module, class module, or user form will be displayed within its own code
window, which means that as you add more modules, the number of windows needed to
work with them will grow. Regardless of the number of modules a project contains, you do
not need to open them all to be able to work with the project. Only the module or user form
you want to edit needs to be opened.
To assist you with navigating the various windows, the Visual Basic Editor provides some
tools to open, switch, and close windows. Opening a module can be accomplished by
doubleclicking the module from within the Project Explorer window. You can also use this method
to switch to a module if it has already been opened.
To switch among the various open windows, you can use the Window menu to select the
desired window. You can also scroll forward through the various windows by pressing
Ctrl+F6 or backward by pressing Shift+Ctrl+F6. When you’re done working with the
contents of a window, you can close it by clicking the Close Window button or pressing Ctrl+F4.
Each of the windows can also be minimized or resized within the parent Visual Basic Editor
window, allowing you to view more than one module window at a time. The Window menu
provides commands to tile the open windows horizontally or vertically or to cascade them.
If you need to view two different sections of the same module, you can split the module win­
dow by using the split window handle or Split command from the Window menu.
Adding Code
Adding code to a project can be done several ways, but the first consideration is to have a con­
tainer to hold the code, such as a code module, a class module, or a user form. The container
you use depends upon the tasks that will be performed by the code you intend to add.
Although it is possible to keep all of your code within one module, it is best to keep your code
separated into different modules grouped by tasks. To add a new module, select the type of
module (module, class module, or user form) needed from the Insert menu or the Insert
button on the Standard toolbar.
Search JabSto ::

Custom Search