XL5: Using Case to Enhance Custom Function Names

ID: Q104529


The information in this article applies to:
  • Microsoft Excel for Windows, versions 4.0, 4.0a, 5.0
  • Microsoft Excel for the Macintosh, versions 4.0, 5.0


SUMMARY

When you enter a worksheet or macro sheet function in Microsoft Excel, if the function is spelled correctly and if the argument syntax is correct, the function will be converted to capital letters when you press the ENTER key.

When you create a custom function, the name that you use to define it determines how the function appears in the Paste Function dialog box and when you enter it correctly on a sheet. This name is case specific. For example, if you use a name that is in all lowercase letters, it will appear in lowercase in the Paste Function dialog box and when you enter it on your sheet.

TIP: Use a name that is a mixture of uppercase and lowercase letters or is in all uppercase letters. That way you'll know that it has correct spelling and syntax when you enter it (because the function name will be converted to the mixture of uppercase and lowercase letters or will appear in all uppercase letters, depending on how you originally defined it).


MORE INFORMATION

In Microsoft Excel 4.0 macro sheets, you can use the Define Name dialog box to define a custom function. If you define a function with the name, MyFunction, and then enter this function on a sheet, the letters "M" and "F" will be displayed as uppercase letters. If you instead define the function using all uppercase letters, MYFUNCTION, it appears in all uppercase when you enter it on a sheet. Function procedures in Visual Basic modules work in a similar manner. That is, the case of a custom function name is determined by how it appears in a variable declaration statement (if there is one) and in how it appears in the procedure.

For example, if you have the following function procedure:


    Dim CUBE as Integer

    Function CUBE(Num)
        CUBE = Num^3
    End Function 


When you enter =cube(10) on a sheet, the function changes case according to the way the name appears in the variable declaration statement and in the procedure: =CUBE(10).

Note that since Visual Basic procedures are compiled as you run them, if, after declaring the variable using all upper case, you enter the function procedure name using only an initial capital, Function Cube(Num), the case for the name in the variable declaration is changed to "Cube." And this is how it will appear when you enter it on a sheet.

Additional query words:

Keywords :
Version : 4.00 4.00a 5.00
Platform : WINDOWS
Issue type :


Last Reviewed: April 7, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.