Microsoft KB Archive/215185

= XL2000: Visual Basic Programming Errors Are Not Reported with User-Defined Functions =

Article ID: 215185

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q215185



SYMPTOMS
In Microsoft Excel, when you create a user-defined function in Microsoft Visual Basic for Applications, the function may not run, in which case, there are no errors reported in the Visual Basic Editor.

For example, in the following user-defined function Option Explicit Function Test(r As Range) As Boolean Dim MyRange As Range MyRange = r   MsgBox "Whatever" End Function no syntax error is reported for line four. Line four should read as follows: Set MyRange = r When the the user-defined function is used in the following Excel formula

=Test(B2)

there is no run-time error reported, but the Excel error #VALUE! appears in the cell containing the formula.



CAUSE
This behavior can occur because the Visual Basic Editor does not recognize some syntax errors in user-defined functions.



WORKAROUND
To work around this issue, when a user-defined function does not return the expected result and there are no coding errors reported, recheck the Visual Basic code for common programming errors.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Additional query words: XL2000

Keywords: kbbug kbpending KB215185

-

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

© Microsoft Corporation. All rights reserved.