Excel CELL function

Function              CELL

Description        Excel CELL function returns information about a given cell. It returns information about address, color, filename, content etc.

Syntax  CELL(info_type, [reference])

info_type   The type of information to return about the reference cell. It gives you many options with a menu.

Info_type Description
address Returns the address of the first cell in reference (as text).
col Returns the column number of the first cell in reference.
color Returns 1 if the first cell in reference is formatted using color. It returns 0 if not formatted with color.
contents Returns the value of the of the reference cell.
filename Returns the file name and full path as text. If the worksheet yet not saved then an empty string is returned.
format Returns a code that corresponds to the number format of the cell. See below for a list of number format codes. If the first cell in reference is formatted with color for values < 0, then “-” is appended to the code. If the cell is formatted with parentheses, returns “() – at the end of the code value.
parentheses Returns 1 the first cell in reference is formatted with parentheses and 0 if not.
prefix Returns a text value corresponding to the ‘label prefix’ of the cell.
protect Returns 1 if the first cell in reference is locked or 0 if not.
row Returns the row number of the first cell in reference.
type Text value corresponding to the type of data in the cell. Returns “b” for blank if the cell is empty, “l” for label if the cell contains a text constant, and “v” for value if the cell contains anything else.
width Returns the cell’s column width.

 

The following table shows meaning of format codes returned by the CELL function.

Format code returned Format code meaning
G General
F0 0
,0 #,##0
F2 0
,2 #,##0.00
C0 $#,##0_);($#,##0)
C0- $#,##0_);[Red]($#,##0)
C2 $#,##0.00_);($#,##0.00)
C2- $#,##0.00_);[Red]($#,##0.00)
P0 0%
P2 0.00%
S2 0.00E+00
G # ?/? or # ??/??
D1 d-mmm-yy or dd-mmm-yy
D2 d-mmm or dd-mmm
D3 mmm-yy
D4 m/d/yy or m/d/yy h:mm or mm/dd/yy
D5 mm/dd
D6 h:mm:ss AM/PM
D7 h:mm AM/PM
D8 h:mm:ss

 

Reference  [optional] The reference from which to extract information. If  the reference is not provided then it will return information of that cell in which typing this formula.