Documentation/Calc Functions/TYPE

    From The Document Foundation Wiki
    Other languages:


    Function name:

    TYPE

    Category:

    Information

    Summary:

    Returns a numeric value indicating the type of the supplied argument.

    Syntax:

    TYPE(Value)

    Returns:

    Returns a number in accordance with the following table:

    Argument type Value returned
    Number 1
    Text 2
    Logical / Boolean 4
    Formula 8
    Error 16
    Array 64

    Arguments:

    Value is an expression, or a reference to a cell containing that expression, whose type is determined.

    • If the argument is a reference to a cell that contains both an error and a formula, the value 16 is returned.
    • If the argument is a reference to an empty cell, the value 1 is returned.

    Additional details:

    • Calc returns the value 8 to indicate a formula cell. This value is not mandated in the function's description in ODF 1.2 and is not used by Microsoft Excel, which returns the type of the formula's returned value.
    • According to Microsoft's web page for the TYPE function, a return value of 128 is possible in Excel (for "compound data"), which is not mandated in the function's description in ODF 1.2.
    • Boolean/logical values are considered as numbers in Calc, whereas in Excel they have their own category.
    • As a result of these different behaviors, care should be taken if interoperability between Calc and Excel is important for your spreadsheet.

    Examples:

    Formula Description Returns
    =TYPE(12.34) Value is a number. 1
    =TYPE(B1)

    where cell B1 contains the number 12.34.

    The referenced cell contains a number. 1
    =TYPE("Well done is better than well said") Value is text. 2
    =TYPE(B2)

    where cell B2 contains the string "Well done is better than well said", without quotation marks.

    The referenced cell contains text. 2
    =TYPE(B3)

    where cell B3 contains the logical value TRUE.

    The referenced cell contains a logical value. 4
    =TYPE(TRUE()) The value is equivalent to a number. 1
    =TYPE(FALSE)

    when the English (USA) locale is selected.

    The value is equivalent to a number. 1
    =TYPE(B4)

    where cell B4 contains the formula =2*PI()*POWER(3; 2).

    The referenced cell contains a formula. 8
    =TYPE(B5)

    where cell B5 contains the formula =SQRT(-4).

    The referenced cell contains an error. An "Invalid argument" error was found (Err:502).

    16
    =TYPE(B6)

    where cell B6 contains either the formula =NA() (#N/A error) or the formula =1/0 (#DIV/0! error).

    The referenced cell contains an error. 16
    =TYPE({3; 5; 7}) The argument is an array. 64
    { =TYPE(D1:D2) }

    entered as an array formula in cells B7:B8.

    Both cells B7 and B8 display the result, whatever the contents of cells D1 and D2. 64

    Related LibreOffice functions:

    ERROR.TYPE

    ERRORTYPE

    ODF standard:

    Section 6.13.33, part 2

    Related (or similar) Excel functions:

    TYPE