Microsoft Office Tutorials and References
In Depth Information
USING THE MACRO RECORDER
The VB Editor scans the instruction for syntax errors. If it finds an error, it
changes the color of the line and may display a message describing the
problem. You can set various options for the VB Editor in the Options
dialog box (accessible by selecting Tools
Options).
As does Excel, the VB Editor has multiple levels of Undo and Redo. Therefore,
if you find that you mistakenly deleted an instruction, you can click the Undo
button (or press Ctrl+Z) repeatedly until the instruction returns. After
undoing the action, you can select EditReDo Delete (or click the ReDo Delete
toolbar button) to redo previously undone changes.
USING THE MACRO RECORDER
Another way to get code into a VBA module is to record your actions by using
Excel’s macro recorder. In many cases, you can use the recorded macro as is. More
often, however, you’ll want to edit the recorded macro to make it more useful.
For more information about recording macros, refer to Chapter 15.
COPYING VBA CODE
This section has covered entering code directly and recording your actions to
generate VBA code. The final method of getting code into a VBA module is to copy it
from another module. For example, you may have written a macro for one project
that would also be useful in your current project. Rather than reenter the code, you
can open the workbook, activate the module, and use the normal Clipboard
copyand-paste procedures to copy it into your current VBA module.
You also can copy VBA code from other sources. For example, you may find a
listing on a Web page or in a newsgroup. In such a case, you can select the text in
your browser (or newsreader), copy it to the Clipboard, and then paste it into a
module.
Saving your project
As with any application, you should save your work frequently while working in
the VB Editor. To do so, use the File
Save command, press Ctrl+S, or click the Save
button on the standard toolbar.
Search JabSto ::




Custom Search