Documentation/Calc Functions/ERRORTYPE

    From The Document Foundation Wiki
    Other languages:


    Function name:

    ERRORTYPE

    Category:

    Spreadsheet

    Summary:

    Determines the error number for a specified cell that is displaying an error.

    A full list of the possible Calc error numbers can be viewed in the Help system. For any type of error, the ERRORTYPE function returns an integer error number which may help you generate bespoke error messages that are more helpful to the intended users of your spreadsheet.

    Syntax:

    ERRORTYPE(Reference)

    Returns:

    Returns a positive integer in the range [501, 540] when an error condition is found in the referenced cell. If no error is found in that cell, then the #N/A error is returned instead.

    Arguments:

    Reference is an expression, or a reference to a cell containing an expression, whose error status is to be determined.

    Additional details:

    • Many of the common errors that arise in cells are highlighted by displaying a short string indicating the general nature of the error (for example, #DIV/0! or #NAME?). However, some other errors result in the display of a less helpful string such as Err:502 or Err:511. Whichever style (of error's indication) is used, clicking the cell enables you to view a more detailed explanation of any error in the Status Bar at the bottom of Calc's window.
    • The Reference argument is not expected to be the error itself, but rather the result of an expression, or a reference to an expression. ERRORTYPE(Err:nnn) does not result in nnn.
    • For those errors that are displayed as an error code of the form Err:nnn (for example, Err:502), the mapping of that error code to an error number is obvious – for example, error code Err:511 is mapped to error number 511. The mapping for other types of error code is given by the following table.
    Mapping error codes to error numbers
    Error code Error number
    #NUM! 503
    #VALUE! 519
    #NULL! 521
    #REF! 524
    #NAME? 525
    #DIV/0! 532
    #N/A 32767

    Examples:

    Use the following table as data for the examples below.

    A B
    1 Formula Returns
    2 =PI() 3.14159265358979 (π)
    3 =SQRT(-3) Err:502
    4 =1/0 #DIV/0!
    5 Err:502 (The string itself, not the result of another expression)
    Formula Description Returns

    =ERRORTYPE(PI()) or
    =ERRORTYPE(A2)

    The argument (or the referenced cell) does not result in an error.

    #N/A

    =ERRORTYPE(SQRT(-3)) or
    =ERRORTYPE(A3)

    The argument (or the referenced cell) results in Err:502 ("invalid argument" error).

    502

    =ERRORTYPE(1/0) or
    =ERRORTYPE(#DIV/0!) or
    =ERRORTYPE(A4)

    In each of these cases, the argument (or the referenced cell) results in #DIV/0! ("division by zero" error).

    532
    =ERRORTYPE(Err:532) The argument is not recognized by this function (see the table in Arguments:) Some error code, not correlated with the argument.
    =ERRORTYPE(A5)

    where cell A5 does not contain some expression that results in some error, but rather contains the text Err:502 itself.

    The result of the referenced cell is not recognized by this function (see the table in Arguments:) #N/A ("Value not found" error).

    Related LibreOffice functions:

    ERROR.TYPE

    ODF standard:

    None. See instead ORG.OPENOFFICE.ERRORTYPE. Not to be confused with ERROR.TYPE.

    Related (or similar) Excel functions:

    None