TYPE Function¶
The TYPE function in Excel is used to return a number that identifies the data type of a value. This is useful for determining whether a cell contains a number, text, logical value, error, or array, enabling type-aware logic in formulas.
Key Features of TYPE:¶
- Returns a numeric code representing the data type of a value.
- Distinguishes between numbers, text, logical values, errors, and arrays.
- Works with cell references, constants, and formula results.
- Useful for building dynamic formulas that adapt based on input types.
- Can detect arrays, enabling different handling for single values vs. ranges.
Syntax:¶
- value: The value whose data type you want to identify. Can be a number, text, logical value, error value, array, or cell reference.
How TYPE Works:¶
TYPEexamines the provided value and determines its data type.- It returns a numeric code based on the type:
- 1 — Number
- 2 — Text
- 4 — Logical value (TRUE or FALSE)
- 16 — Error value
- 64 — Array
- If the value is a cell reference,
TYPEevaluates the contents of the referenced cell. - If a formula is passed,
TYPEevaluates the result of the formula and returns the type of that result.
Examples:¶
1. Number:¶
Result:
2. Text:¶
Result:
3. Logical Value:¶
Result:
4. Error Value:¶
Result:
5. Array:¶
Result:
6. Cell Reference Containing a Number:¶
If A1 contains 100:
Result:
7. Formula Result:¶
Result:
8. Conditional Logic Based on Type:¶
Result:
Notes:¶
TYPEdoes not distinguish between different kinds of numbers (integers, decimals, dates, times) — all return1.- All error types (
#N/A,#VALUE!,#REF!,#DIV/0!,#NAME?,#NULL!,#NUM!) return16. - When used on an empty cell,
TYPEreturns1(number), since empty cells are treated as zero. TYPEevaluates the result of a formula, not the formula itself. For example,TYPE(1+"text")returns16because the formula produces a#VALUE!error.TYPEis particularly useful in LAMBDA functions and helper formulas where inputs may vary in type.
Applications:¶
- Input Validation: Verify that user inputs are of the expected data type before processing.
- Dynamic Formulas: Build formulas that handle different data types gracefully by branching on
TYPE. - Error Detection: Identify cells containing error values for cleanup or reporting.
- Array Detection: Determine whether a value is a single item or an array for conditional processing.
- Debugging: Diagnose unexpected formula results by checking the types of intermediate values.
Related Functions:¶
- ISNUMBER: Returns TRUE if the value is a number.
- ISTEXT: Returns TRUE if the value is text.
- ISLOGICAL: Returns TRUE if the value is a logical value.
- ISERROR: Returns TRUE if the value is any error.
- ISNA: Returns TRUE if the value is the #N/A error.
- N: Converts values to numbers.
Tip: Use
TYPEwhen you need a single formula to handle multiple data types. Instead of nestingISNUMBER,ISTEXT, andISERRORchecks, a singleTYPEcall can drive aSWITCHor nestedIFto branch on the data type efficiently.