Difference between revisions of "Documentation/How Tos/Calc: TYPE function"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Automated text replacement %s)
m
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
+
{{DISPLAYTITLE:TYPE function}}
 +
{{Documentation/CalcFunc InformationTOC
 +
|ShowPrevNext=block
 +
|PrevPage=Documentation/How_Tos/Calc:_NA_function
 +
|NextPage=Documentation/How_Tos/Calc:_Logical_functions
 +
}}__NOTOC__
  
 
== TYPE  ==
 
== TYPE  ==
Line 7: Line 12:
 
<tt>'''TYPE(value)'''</tt>
 
<tt>'''TYPE(value)'''</tt>
  
: Returns the type of value as a number:  <tt>'''1'''</tt> = number, <tt>'''2'''</tt> = text, <tt>'''4'''</tt> = logical value, <tt>'''8'''</tt> = formula, <tt>'''16'''</tt> = error value.
+
: Returns the type of value as a number:  <tt>'''1'''</tt> = number, <tt>'''2'''</tt> = text, <tt>'''4'''</tt> = logical value, <tt>'''8'''</tt> = formula, <tt>'''16'''</tt> = error value, <tt>'''64'''</tt> = array.
 
   
 
   
 
: If a cell contains both an error and a formula, <tt>'''16'''</tt> (error value) is returned.
 
: If a cell contains both an error and a formula, <tt>'''16'''</tt> (error value) is returned.
Line 19: Line 24:
 
: where cell C3 contains <tt>'''=NA()'''</tt> returns <tt>'''16'''</tt>, because <tt>'''NA()'''</tt> returns the error value <tt>'''#N/A'''</tt>.  
 
: where cell C3 contains <tt>'''=NA()'''</tt> returns <tt>'''16'''</tt>, because <tt>'''NA()'''</tt> returns the error value <tt>'''#N/A'''</tt>.  
  
{{Documentation/SeeAlso|
+
<i>Advanced topic:</i>
 +
 
 +
For more information on arrays, see [[Documentation/How Tos/Using Arrays|Using arrays]].
 +
 
 +
<tt>'''TYPE({3;5;7})'''</tt>
 +
: returns <tt>'''64'''</tt>
 +
 
 +
<tt>'''{=TYPE(A1:B1)}'''</tt> entered as an array formula in cells A3:B3
 +
: returns <tt>'''64'''</tt> in cells A3:B3 (whatever the contents of cells A1 and B1), as A1:B1 is an internal array in the array formula.
 +
 
 +
<tt>'''TYPE(A1:B1)'''</tt> entered as a normal formula in both cells A3 and B3
 +
: returns <tt>'''TYPE(A1)'''</tt> in cell A3, and <tt>'''TYPE(B1)'''</tt> in cell B3. Here, Calc finds the row/column intersection of the formula cell with range A1:B1, to determine a reference to the single cell to examine.
 +
 
 +
<tt>'''TYPE(D1)'''</tt>, where D1:D2 contain the array formula {={4;2}}
 +
: returns <tt>'''8'''</tt>. Here the result is for D1's content, which although part of an array, is not the array itself.
 +
 
 +
=== Issues: ===
 +
* Calc returns <tt>'''8'''</tt> for a formula. Excel returns the TYPE of the formula's returned value; it has no return value to recognize a formula.
 +
 
 +
{{SeeAlso|EN|
 
* [[Documentation/How_Tos/Calc: CELL function|CELL]]
 
* [[Documentation/How_Tos/Calc: CELL function|CELL]]
  
 
* [[Documentation/How_Tos/Calc: Information functions|Information functions]]
 
* [[Documentation/How_Tos/Calc: Information functions|Information functions]]
 +
 +
* [[Documentation/How Tos/Using Arrays|Using arrays]]
  
 
* [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]]
 
* [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]]
 
* [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}}
 
* [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}}
[[Category: Documentation/Reference/Calc]]
+
[[Category: Documentation/Reference/Calc/Information functions]]

Latest revision as of 13:31, 31 January 2024

TYPE

Returns the type of value (number, text, etc.).

Syntax:

TYPE(value)

Returns the type of value as a number: 1 = number, 2 = text, 4 = logical value, 8 = formula, 16 = error value, 64 = array.
If a cell contains both an error and a formula, 16 (error value) is returned.
A blank cell is classed as a number here, and 1 is returned.

Example:

TYPE(C2)

where cell C2 contains dog returns 2, because dog is text.

TYPE(C3)

where cell C3 contains =NA() returns 16, because NA() returns the error value #N/A.

Advanced topic:

For more information on arrays, see Using arrays.

TYPE({3;5;7})

returns 64

{=TYPE(A1:B1)} entered as an array formula in cells A3:B3

returns 64 in cells A3:B3 (whatever the contents of cells A1 and B1), as A1:B1 is an internal array in the array formula.

TYPE(A1:B1) entered as a normal formula in both cells A3 and B3

returns TYPE(A1) in cell A3, and TYPE(B1) in cell B3. Here, Calc finds the row/column intersection of the formula cell with range A1:B1, to determine a reference to the single cell to examine.

TYPE(D1), where D1:D2 contain the array formula {={4;2}}

returns 8. Here the result is for D1's content, which although part of an array, is not the array itself.

Issues:

  • Calc returns 8 for a formula. Excel returns the TYPE of the formula's returned value; it has no return value to recognize a formula.



See Also
Retrieved from "https://wiki.openoffice.org/w/index.php?title=Documentation/How_Tos/Calc:_TYPE_function&oldid=259822"
Views
Personal tools
Navigation
Tools
In other languages