Purpose
Return value
Syntax
=T(value)
- value - The value to return as text.
Using the T function
The Excel T function converts numbers, dates, and the logical values TRUE and FALSE into empty strings . Text values and errors are not converted and pass through unaffected. You can use the T function to remove values that are not text.
The T function takes one argument, value , which can be a cell reference, a formula result, or a hardcoded value.
Examples
The T function returns text when given a text value and an empty string ("") for numbers, dates, and the logical values TRUE and FALSE. For example:
=T("apple") // returns "apple"
=T("NASA") // returns "NASA"
=T(100) // returns ""
=T(FALSE) // returns ""
In most cases, the T function is unnecessary, because Excel automatically converts values when needed. The T function is provided for compatibility with other spreadsheet programs.
Errors are not affected by the T function:
=T(3/0) // returns #DIV/0!
=T("#N/A") // returns #N/A
Notes
- The T function removes numeric values. The N function removes text values.
Purpose
Return value
Syntax
=TYPE(value)
- value - The value to check the type of.
Using the TYPE function
The TYPE function returns a numeric code representing “type” in 5 categories: number = 1, text = 2, logical = 4, error = 16, and array = 64. The TYPE function takes one argument, value , which can be a reference, a formula, or a hardcoded value. The table below shows the possible type codes returned from TYPE and the meaning of each:
| Type code | Meaning |
|---|---|
| 1 | Number |
| 2 | Text |
| 4 | Logical value |
| 16 | Error value |
| 64 | Array |
| 128 | Compound data |
Examples
The TYPE function returns a numeric code:
=TYPE(100) // returns 1 for numbers
=TYPE("apple") // returns 2 for text
=TYPE(TRUE) // returns 4 for logicals
TYPE returns 16 for errors:
=TYPE(3/0) // returns 16
=TYPE(NA()) // returns 16
If TYPE is given an array constant , or a range , the result is 64:
=TYPE({1;2;3}) // returns 64
=TYPE(A1:C1 // returns 64
TYPE returns 128 for compound data, like LAMBDA functions:
=TYPE(LAMBDA(x,x*x)) // returns 128
Notes
- You can’t use TYPE to test for a formula, because TYPE evaluates the result.
- Excel dates and times are numeric values, and therefore return 1.