Microsoft Office Tutorials and References
In Depth Information
Understanding Functions Versus Subs
Figure 206-2 shows the listing of a custom function named User. This function simply returns the
name of the user (as specified in the Excel Options dialog box). A Function procedure looks
much like a Sub procedure. Notice, however, that Function procedures begin with the keyword
Function and end with an End Function statement.
Here’s an example of a worksheet formula that uses this function:
This formula assumes that the User function is defined in your Personal Macro Workbook. If the
function is defined in the workbook that contains the formula, you can omit the file reference and
use this formula:
Figure 206-2: A Function procedure that returns the user’s name.