Microsoft Office Tutorials and References
In Depth Information
CREATE AN EVENT HANDLER MACRO
5.
If necessary, click the + sign to the left of Microsoft Excel Objects to expand
the view of worksheets and the workbook. You now see an entry for each
worksheet in the workbook and an entry for ThisWorkbook .
Double-click ThisWorkbook . Alternatively, right-click ThisWorkbook and
choose View Code (Figure 123).
6.
Part
3
Figure 123. You need to access the code pane for
the ThisWorkbook object.
7.
If you are copying a macro from the web, paste it to the code window now.
If you are typing the macro yourself, follow steps 8 and 9.
8.
From the left dropdown at the top of the code window, choose Workbook .
By default, Excel types the start of a Workbook_Open macro in the code
window. You can delete it later, if needed.
9.
Open the right dropdown at the top of the code window. These are all
the workbook-level events that can have a macro associated with them.
Choose BeforePrint from the dropdown. Excel types the start of the
Workbook_BeforePrint macro in the code window.
The process is similar if you want to create a worksheet-level event handler.
In that case, you follow the steps above, but in step 6, you double-click the
worksheet name in the Project Explorer, and in step 8, you choose Worksheet
from the left dropdown. Excel automatically creates the start of the Worksheet_
SelectionChange macro.
Summary: You need to type event handler macros in special code panes
attached to the worksheet or workbook.
 
Search JabSto ::




Custom Search