Microsoft KB Archive/213199

= XL2000: Custom Functions Cannot Change Microsoft Excel Environment =

PSS ID Number: 213199

Article Last Modified on 9/11/2002

-

The information in this article applies to:


 * Microsoft Excel 2000
 * Microsoft Visual Basic for Applications

-



This article was previously published under Q213199





SUMMARY
In Microsoft Excel 2000, you can create a user-defined function that returns a custom calculation by using Visual Basic for Applications. However, user-defined functions cannot perform actions that change the Excel environment when called by a formula in a worksheet cell.



MORE INFORMATION
A user-defined function called by a formula in a worksheet cell cannot change the environment of Excel. This means that such a function cannot do any of the following:
 * Insert, delete, or format cells on the worksheet.
 * Change another cell's value.
 * Move, rename, delete, or add sheets to a workbook.
 * Change any of the environment options, such as calculation mode or screen views.
 * Set properties or execute most methods.

The purpose of user-defined functions is to allow the user to create a custom function that is not included in the functions that ship with Excel. The functions included in Excel also cannot change the environment. Functions can perform a calculation that returns either a value or text to the cell that they are entered in. Any environmental changes should be made through the use of a Visual Basic subroutine.

Additional query words: vba XL2000

Keywords: kbhowto kbProgramming KB213199

Technology: kbExcel2000 kbExcel2000Search kbExcelSearch kbExcelWinSearch kbVBASearch kbZNotKeyword3 kbZNotKeyword6

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© 2003 Microsoft Corporation. All rights reserved.