Macros don't always work perfectly . That is, you might make a mistake while recording the macro, or you might leave out a step. You don't need to worry about a macro that displays an error message because you can always fix those macro errors in Excel by editing, adding, and removing commands from the macro instructions. A macro might need additional commands or actions, or you might want to delete some command or action from the macro. What if you want to make changes to existing macro commands and actions or correct errors in a macro that doesn't run properly? No problem. You can make any of these changes to a macro by editing the macro. Looking at Macro CodeMacro instructions are written in Visual Basic, a fairly easy-to-use programming language. With the macro sheet in view onscreen, you can use Excel's editing commands to make changes to the Visual Basic instructions. You can remove macro commands, edit the specific contents of a cell in the macro worksheet, or even insert new commands into the middle of a macro. Of course, some changes require knowledge of Visual Basic. Specific commands that relate to actions that you want are described in the Microsoft Excel manual that comes with the software. You can view macro code in the macro sheet by switching to that sheet. To open the macro sheet, choose Tools, Macro, Macros. In the Macro dialog box, select the Font_change macro. Click the Edit button.
The Microsoft Visual Basic window appears, as shown in Figure 49.5. You should see the Visual Basic toolbar and three window panes:
Figure 49.5. The Microsoft Visual Basic window.
At the far right end of the Visual Basic toolbar, notice the line and column indicator: Ln X, Col X. These indicators tell you the line and column where the insertion point is located in the active pane. To activate a pane, simply click the pane. Editing the MacroYou can insert a command manually, remove a command, or edit a macro command on the macro sheet to make changes to the macro. You'll work with the Visual Basic Instructions pane on the right to make your changes. To get a better view of what you're doing in the Visual Basic Instructions pane, click the Maximize button in the upper-right corner of the pane. Excel enlarges the pane so that you see more macro instructions. The following steps teach you how to edit the macro. You change the macro's font size from 22 point to 28 point.
|