Contact

TYPE Function (LibreOffice Calc)

Information Intermediate LibreOffice Calc LibreOffice 3.0

The TYPE function in LibreOffice Calc returns a numeric code representing the underlying data type of a value. It is essential for debugging formulas, validating input, and building dynamic logic based on data types.

Verification status: Consult the documentation and examples below. Native application testing has not been documented for this guide. How formula examples are checked

The **TYPE** function returns a numeric code representing the underlying data type of a value in LibreOffice Calc. It is essential for debugging formulas, validating input, and building dynamic logic that adapts to numbers, text, logical values, arrays, and errors. TYPE is one of the most powerful diagnostic tools in Calc.

What the TYPE Function Does

  • Returns a numeric code describing the data type
  • Works with literals, formulas, references, and arrays
  • Useful for debugging and dynamic logic
  • Helps distinguish between text, numbers, logical values, errors, and arrays

It is designed to be precise, diagnostic, and essential for advanced spreadsheets.

Syntax

TYPE(value)

Arguments

  • value:
    Any value, expression, or cell reference.

TYPE Return Codes

Code Meaning
1 Number
2 Text
4 Logical value (TRUE/FALSE)
16 Error value
64 Array

These codes are consistent across LibreOffice, Excel, and most spreadsheet engines.

Basic Examples

Check the type of A1

=TYPE(A1)

Check a number

=TYPE(42)

Returns 1.

Check text

=TYPE("Hello")

Returns 2.

Check a logical value

=TYPE(TRUE)

Returns 4.

Check an error

=TYPE(#REF!)

Returns 16.

Advanced Examples

Detect numeric-looking text

=TYPE("123")

Returns 2 (text), not 1.

Detect empty-string formulas

=TYPE("")

Returns 2 (text).

Detect dates

=TYPE(DATE(2024;1;1))

Returns 1 — dates are numbers.

Detect times

=TYPE(TIME(12;0;0))

Returns 1.

Detect array formulas

=TYPE(A1:A10)

Returns 64 in array context.

Detect errors in formulas

=TYPE(A1 / 0)

Returns 16.

Build dynamic logic based on type

=IF(TYPE(A1)=1; "Number"; IF(TYPE(A1)=2; "Text"; "Other"))

Validate user input

=IF(TYPE(A1)=1; "OK"; "Enter a number")

Detect logical results from comparisons

=TYPE(A1 > 10)

Returns 4.

Edge Cases and Behavior Details

Blank cells return TYPE = 1?

No — blank cells behave differently:

=TYPE(A1)

Returns an error if A1 is empty.
Use ISBLANK instead.

Empty string "" is text

=TYPE("")

Returns 2.

Text that looks like a number is still text

=TYPE("42")

Returns 2.

Array detection requires array context

=TYPE(A1:A10)

Returns 64 only in array formulas.

Error values always return 16

=TYPE(#N/A)  
=TYPE(#REF!)  
=TYPE(#DIV/0!)

All return 16.

Logical values always return 4

=TYPE(FALSE)

Returns 4.

Common Errors and Fixes

TYPE returns an error

Cause:

  • Referencing a blank cell
  • Passing an invalid reference
  • Using TYPE on a range outside array context

Fix:
Wrap with IFERROR or validate input.

TYPE returns unexpected code

Cause:

  • Dates and times are numbers
  • Empty strings are text
  • Comparisons return logical values
  • Arrays require array context

TYPE used incorrectly on ranges

=TYPE(A1:A10)

Returns 64 only in array formulas; otherwise may error.

Best Practices

  • Use TYPE for debugging complex formulas
  • Use TYPE to distinguish numeric text from real numbers
  • Use TYPE to detect logical vs numeric results
  • Use TYPE to classify errors vs valid values
  • Use TYPE with INDIRECT and ADDRESS to validate dynamic references
TYPE is your diagnostic X‑ray — it reveals the true nature of any value, no matter how it appears on the surface.
  • Use ISNUMBER, ISTEXT, ISLOGICAL for simple type checks
  • Use ISERROR, ISERR, ISNA for error detection
  • Use INDIRECT and ADDRESS for dynamic references
  • Use IF to build type‑dependent logic

By mastering TYPE and its companion functions, you can build intelligent, adaptive, and error‑resistant spreadsheets in LibreOffice Calc.