Home »
ExcelBuiltInFunctions »
ExcelInformationFunctions »
ExcelCellFunction
The Excel CELL Function
Basic Description
The Excel CELL function returns information about a given cell. This can be information in relation
to the contents, formatting or location of the cell.
The format of the function is:
CELL( info_type, reference )
where the arguments are as follows:
info_type 
 
Specifies the type of information to be returned. This can be either:
"address" 
 
returns the cell reference, as text 
"col" 
 
returns the cell's column number 
"color" 
 
returns 1 if the cell is formatted so that negative values are colored, or 0 otherwise 
"contents" 
 
returns the value of the cell (not a formula) 
"filename" 
 
returns the full path and filename of the workbook and worksheet that the supplied cell is in
(returns "" (blank) if the workbook containing the cell has not yet been saved)

"format" 
 
returns a text value representing the formatting style of the cell. This may be either:
"G" 
General Format or # ?/? or # ??/?? 
"F0" 
0 
"D1" 
dmmmyy or ddmmmyy 
",0" 
#,##0 
"D2" 
dmmm or ddmmm 
"F2" 
0.00 
"D3" 
mmmyy 
",2" 
#,##0.00 
"D4" 
m/d/yy or mm/dd/yy or m/d/yy h:mm 
"C0" 
Currency Format (no decimal places) 
"D5" 
mm/dd 
"C2" 
Currency Format (2 decimal places) 
"D6" 
h:mm:ss AM/PM 
"P0" 
0% 
"D7" 
h:mm AM/PM 
"P2" 
0.00% 
"D8" 
h:mm:ss 
"S2" 
0.00E+00 
"D9" 
h:mm 
Added to the end of Format Types: 
"" 
indicates cell is formatted in color for negative values 
"()" 
indicates cell is formatted with parentheses for positive or all values 

"parentheses" 
 
returns 1 if the cell is formatted with parentheses for positive or all values;
returns 0 otherwise 
"prefix" 
 
returns a text value corresponding to the 'label prefix' of the cell 
"protect" 
 
returns 1 if the cell is locked and 0 otherwise 
"row" 
 
returns the cell's row number 
"type" 
 
returns a text value corresponding to the type of data in the cell.
This can be either "b" for blank (or empty); "l" for label (ie. text constant),
or "v" for value (for any other data type) 
"width" 
 
returns the cell's column width 

reference 
 
The cell that the information is to be returned for.
Note:
 
If a range of cells is supplied, the returned information relates to the top left cell of the range 
 
If the reference is omitted, then the returned information relates to the last cell that was changed 

Examples of the Excel Cell Function
The following spreadsheets shows examples, of the Excel Cell function being used to return
different properties of the cell A1. It should be noted that, in the example spreadsheet
below, the cell A1 is formatted with the Custom Format #,##0; [Red]  #,##0
(see the Excel Formatting page
for more information on different formatting types).
Formulas:

Results:

Note:
If the formatting of cell A1 in the above spreadsheet is changed, the formulas in cells B1B12 will
not automatically recalculate. You can force them to recalculate by pressing the F9 key.
Note that, in cell B6 of the above example spreadsheet, the "format" type is returned as ",0".
This is comprised of two parts: the ",0" part, which represents the #,##0 number format,
and the "" part, which indicates that the cell is formatted in color for negative values.
Further information and examples of the Excel Cell Function can be found on the
Microsoft Office website.
Excel Cell Function Common Error
If you get an error returned from the Excel Cell Function, this is likely to be the Excel #VALUE! error :
Common Error
#VALUE! 
 
Occurs if the supplied info_type argument is not one of the recognised types (see the table at the top of this page)
