Excel CELL Function
The CELL function returns the requested information about a specified cell, such as the cell’s location, contents, formatting, and more.
The table below lists all possible values accepted by the CELL function that can be used as the info_type argument.
Note: The cell below indicates the upper-left (first) cell in reference
|"address"||Returns the address of the cell (as text)|
|"col"||Returns the column number of the cell|
|"color"||Returns 1 if the cell is formatted in color for negative numbers; Returns 0 otherwise|
|"contents"||Returns the value of the cell. If the cell contains a formula, the calculated value will be returned|
|"filename"||Returns the file name and full path to the workbook that contains the cell as text. If the worksheet that contains the reference has not yet been saved, an empty string ("") will be returned|
|"format"||Returns a format code that corresponds to the number format of the cell as text. For more information, please see CELL format codes.|
|"parentheses"||Returns 1 if the cell is formatted with parentheses for positive or all values; Returns 0 otherwise|
|"prefix"||Returns a text value that corresponds to the label prefix of the cell:
|"protect"||Returns 1 if the cell is locked; Returns 0 otherwise|
|"row"||Returns the row number of the cell|
|"type"||Returns a text value that corresponds to the type of data in the cell:
|"width"||Returns 2 items in an array:
Note: The "color", "filename", "format", "parentheses", "prefix", "protect" and "width" values are not supported in Excel for the web, Excel Mobile, and Excel Starter.
The table below shows the text codes that correspond to specific number formats of the cell when info_type is set to "format".
|Format code returned||Corresponding number format|
|G||# ?/? or # ??/??|
|D4||m/d/yy or m/d/yy h:mm or mm/dd/yy|
|D1||d-mmm-yy or dd-mmm-yy|
|D2||d-mmm or dd-mmm|
Note: The number formats above are all built-in formats. The "-" will be added at the end of the code values if the cell is formatted in color for negative values. If the cell is formatted with parentheses for positive or all values, "()" will be returned at the end of the code.
The CELL function returns the requested information.
- info_type must be enclosed in double quotes ("") if it’s directly entered in a CELL formula. If you don’t type the argument but reference it, no double quotes are needed.
- reference is optional for some info_type values. However, it’s recommended to use an address like A1 to avoid unexpected results.
- You must recalculate the worksheet (press F9) to update the results of the CELL function if you later apply a different format to the referenced cell.
- CELL will return the #VALUE! error if info_type is not one of the recognized types.
- CELL will return the #NAME? error if either of the arguments is text values that are not enclosed in double quotes.
To get the information of the cell B3 according to the info types as shown in the below table, please copy or enter the formula below in the top cell, press Enter to get the result, and then drag the fill handle (at the lower right corner of the result cell) down to apply the formula to below cells.
√ Note: The dollar signs ($) above indicate absolute references, which means the reference in the formula won't change when you move or copy the formula to other cells. However, there are no dollar signs added to the info_type since you want it to be dynamic.
Also, you can enter the info_type argument directly in the formula as shown below. Make sure it is enclosed with double quotes: