XL: Custom Functions Can't Change Microsoft Excel Environment

ID: Q170787


The information in this article applies to:


SUMMARY

In the versions of Microsoft Excel listed at the beginning of this article, 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 Microsoft 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 Microsoft Excel. This means that such a function cannot do any of the following:

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 Microsoft Excel. The functions included in Microsoft 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.


REFERENCES

"Visual Basic User's Guide" version 5.0, Chapter 4, "What Is a Visual Basic Procedure"

"Writing a user-defined worksheet function", Microsoft Excel 7.0 Visual Basic Help File.

Additional query words: vba


Keywords          : kbprg kbdta PgmOthr KbVBA 
Version           : MACINTOSH:5.0,5.0a,98; WINDOWS:5.0,5.0a,5.0c
Platform          : MACINTOSH WINDOWS 
Issue type        : kbinfo 

Last Reviewed: July 13, 1999