Microsoft Office Tutorials and References
In Depth Information
Creating a Function Procedure
You can create a Function procedure in an existing code module by opening the module in
the Visual Basic Editor by typing the following:
Function name ()
You will need to name the function and put instructions in the middle where the ellipsis is
now, but you can do it much more quickly using the Add Procedure dialog box.
To add a Function procedure to a code module, follow these steps:
Click Tools, Macro, Visual Basic Editor to display the Visual Basic Editor.
If necessary, click Insert, Module to create a new code module (or if you want to create
a new module for organizational purposes).
Click Insert, Procedure to display the Add Procedure dialog box.
Type the name of your procedure in the Name box.
Select the Function option button.
Note As with Sub procedures, you can make your Function procedures available to pro
cedures in every other workbook by putting the Public keyword in front of the declaration.
The Public keyword is added by default when you add a procedure using the Insert Proce
dure dialog box.