XL: ERROR.TYPE Help Example Returns Incorrect ResultLast reviewed: February 5, 1998Article ID: Q179379 |
The information in this article applies to:
SYMPTOMSWhen you use the ERROR.TYPE function, the value you expect is not returned according to the example in Help. If the cell that is being compared has an error value, the example works properly; however, if this cell contains a value (a number or text), the example in Help returns #N/A error rather than the value of the cell you are testing.
CAUSEThis problem occurs when you evaluate a cell that does not match one of the expected error types as in the following example:
A1: 5 A2: 10 A3: =IF(ERROR.TYPE(A1)=7, "Value is not available", A2)Because A1 contains a value and not an error, the ERROR.TYPE function returns a #N/A error instead of the condition specified in the IF argument, which is the contents of cell A2.
WORKAROUNDTo work around this problem, use the ISERROR function to determine if the ERROR.TYPE function is returning an error. If the function returns an error, return a value instead. For example, replace the formula in the "Cause" section with the following formula:
=IF(ISERROR(ERROR.TYPE(A1)),A2,IF(ERROR.TYPE(A1)=7, "Value is not available","")) STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThe Example in Microsoft Excel Help is as follows:
The following formula checks cell E50 to see whether it contains a #N/A error value. If it does, the text "Value is not available" is displayed. Otherwise, the value in E50 is returned. IF(ERROR.TYPE(E50)=7, "Value is not available", E50)As the syntax shows, the ERROR.TYPE function returns a #N/A error if it refers to a cell that contains a proper value. This error also causes the IF statement to return such a value. You cannot use this function this way without first trapping the error returned by ERROR.TYPE. This function was first included in Microsoft Excel 5.0. In this version of Excel, the function is a macro function that can also be used on a worksheet. The example given in Excel versions 5.0 and 7.0 is as follows:
The following macro formula checks the cell named Ratio to see if it contains a #DIV/0! error value. If it does, a subroutine named DivisionByZero is run. IF(ERROR.TYPE(Ratio)=2,DivisionByZero())However, this example does not work because a subroutine cannot be run from a worksheet statement. This formula works if there is an error in the cell and DivisionByZero is a user-defined function; however, the formula fails if there is a value in the cell. If you are using this example, use the following formula to replace the example in Help:
=IF(ISERROR(ERROR.TYPE(Ratio)),Ratio,IF(ERROR.TYPE(Ratio)=2, DivisionByZero(),"")) |
Additional query words: XL97 XL5 XL7
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |