XL5: Using Case to Enhance Custom Function Names

Last reviewed: September 12, 1996
Article ID: Q104529
The information in this article applies to:
  • Microsoft Excel for Windows, version 4.0, 4.0a, 5.0
  • Microsoft Excel for the Macintosh, version 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.


KBCategory: kbusage
KBSubcategory:

Additional reference words: 5.00



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 12, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.