# How to use the TYPE function

**What is the TYPE function?**

The TYPE function returns a number representing what type of data is returned by a function or formula.

#### Table of Contents

## 1. Introduction

**What is a formula?**

A formula in Excel is an expression that calculates a value based on the values in other cells. Formulas must start with an equals sign "=" and can contain cell references, math operators, functions, constants, arrays, etc. They are used to perform calculations in Excel.

**Related TYPE functions**

Excel Function | Description |
---|---|

TYPE(value) | Returns a number indicating the data type of value |

INFO(type_text) | Returns information about the current operating environment |

ERROR.TYPE(error_val) | Returns a number corresponding to the type of error in error_val |

CELL(info_type, reference) | Returns information about the formatting, location, or contents of a cell |

## 2. Syntax

TYPE(*value*)

value |
Required. Any value. |

If value is | Type function returns |
---|---|

Number |
1 |

Text |
2 |

Logical value |
4 |

Error value |
16 |

Array |
64 |

**What is a number?**

A number in Excel refers to numeric data entered without quotation marks and are aligned to the right. Numbers can be integers, decimals, percentages, formatted numbers, results of formulas.

**What is text in Excel?**

Excel tries to identify inserted values automatically, text values are left-aligned. Boolean values and error values are centered in cells, and numerical values are right-aligned. You can change the alignment if you like.

Cells containing text values evaluates to TRUE by the ISTEXT function. The ISNTEXT function lets you check a value programmatically in a formula instead of visually identify values by their position in a cell.

**What is an error value?**

An error value is returned when something is wrong, it may be a formula that contains an error, a function with missing parameters or a misspelled function etc.

Here are a few common errors in Excel:

**#NULL error**- This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.**#SPILL error**- The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.**#DIV/0 error**- This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically. Use the "Evaluate formula" tool to pinpoint the exact location in the formula where this error occurs. The "Evaluate formula" tool is located on the "Formulas" tab on the ribbon. Select the cell containing the #DIV/0 error and then press with left mouse button on the "Evaluate formula button".**#VALUE error**- The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.**#REF error**- The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.**#NAME error**- The #NAME error happens if you misspelled a function or a named range.**#NUM error**- The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.**#N/A error**- The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.**#GETTING_DATA error**- The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.

**What is an array in Excel?**

Some functions return an array of values instead of a single value. Excel 365 handles these arrays automatically whereas previous versions need to be entered as an array formula. For example, the FREQUENCY function returns multiple values.

You can also create a formula that returns multiple values, in Excel 365 they are named dynamic array formulas and in earlier versions named array formulas. The most simple dynamic array formula I know is this: = A1:A2, it returns two values populated in cells A1 and A2.

## 3. Example

This example demonstrates how to use the TYPE function. The TYPE function returns a number representing what type of data is returned. Cells B3:B8 contains the function and an argument. Cells C3:C8 contains the actual formula in the corresponding adjacent cell on the same row, this makes it easier to see what each cell contains.

The first example in cell B3 demonstrates the output number corresponding to "A" which is a text string.

Formula in cell B3:

The formula in cell B3 returns 2 which represents text.

The second example in cell B4 demonstrates the output number corresponding to 1 which is a numeric value.

Formula in cell B4:

The formula in cell B4 returns 1 which represents number.

The third example in cell B5 shows the output number corresponding to 0 (zero) which is a numeric value.

Formula in cell B4:

The formula in cell B4 returns 1 which represents number.

The fourth example in cell B5 demonstrates the output number corresponding to TRUE which is a boolean value.

Formula in cell B5:

The formula in cell B4 returns 4 which represents boolean value TRUE or FALSE.

The fourth example in cell B6 demonstrates the output number corresponding to #DIV/0! which is an error value.

Formula in cell B6:

The formula in cell B4 returns 16 which represents an error value.

The fifth example in cell B7 demonstrates the output number corresponding to an array which is a multiple values.

Formula in cell B7:

The formula in cell B4 returns 64 which represents the number corresponding to an array.

You can't use the TYPE function to determine the type of value in a specific cell using a cell reference, the TYPE function will then return the type of the formula's returning value. Even if the formula returns an array the TYPE function returns only the type of the value displayed in that cell.

## 4. TYPE function array

This example demonstrates that the TYPE function processes the value that the formula returns and not the array. The picture above demonstrates an array entered in cell range B3:B4:

The TYPE function returns 1 and 2 which represents number type and text type, however, the output is an array and should return 64.

## 5. Example 3

This example shows how to process an array using the BYROW function, as well as aggregate the values and display a summary. The image above shows different values with different data types in cell range B3:B10.

Excel 365 dynamic array formula in cell D3:

This formula works only in Excel 365, it contains a few functions available only in Excel 365. The formula spills values automatically to cells below and to cells to the right as far as needed.

The formula returns an array that contains the data types in the first column (D3:D6) and their count meaning how many values of each data type are present in cell range B3:B10.

- The first data typ 1 represents "number", it has 2 instances in B3:B10 which are B4 and B8.
- The second data type is 2 which represents text. It has 4 instances in cells B3,B6,B7, and B9.
- The third data type is 4 meaning boolean values. Only one instance exists and that value is in cell B5.
- The last data typ is 16 and it represents error values. Also only one error is displayed which is in cell B10.

Here is a quick break-down of the formula:

- TYPE(a): a is a variable. TYPE returns the data type of the variable.
- LAMBDA(a, TYPE(a)): LAMBDA function is required for the BYROW function to work properly. It passes each value in the row to the TYPE function.
- BYROW(B3:B10,LAMBDA(a,TYPE(a))): The BYROW function passes each value in cells B3:B10 to the LAMBDA function.
- GROUPBY( BYROW(B3:B10,LAMBDA(a,TYPE(a))) , BYROW(B3:B10,LAMBDA(a,TYPE(a))) ,COUNTA): The GROUPBY function aggregates values,
- LET(x, BYROW(B3:B10,LAMBDA(a,TYPE(a))), GROUPBY(x,x,COUNTA)): The LET function lets you shorten formulas if repeated calculations are present.

### Functions in 'Information' category

The TYPE function function is one of 19 functions in the 'Information' category.

## How to comment

How to add a formula to your comment<code>Insert your formula here.</code>

Convert less than and larger than signsUse html character entities instead of less than and larger than signs.

< becomes < and > becomes >

How to add VBA code to your comment[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

How to add a picture to your comment:Upload picture to postimage.org or imgur

Paste image link to your comment.

Contact OscarYou can contact me through this contact form