Returns information about the formatting, location, or contents of the upper-left cell in a reference.
Syntax
CELL(info_type,reference)
Info_type is a text value that specifies what type of cell information you want. The following list shows the possible values of info_type and the corresponding results.
Info_type |
Returns |
"address" |
Reference of the first cell in reference, as text. |
"col" |
Column number of the cell in reference. |
"color" |
1 if the cell is formatted in color for negative values; otherwise returns 0 (zero). |
"contents" |
Contents of the upper-left cell in reference. |
"filename" |
Filename (including full path) of the file that contains reference, as text. Returns empty text ("") if the worksheet that contains reference has not yet been saved. |
"format" |
Text value corresponding to the number format of the cell. The text values for the various formats are shown in the following table. Returns "-" at the end of the text value if the cell is formatted in color for negative values. Returns "()" at the end of the text value if the cell is formatted with parentheses for positive or all values. |
"parentheses" |
1 if the cell is formatted with parentheses for positive or all values; otherwise returns 0. |
Info_type |
Returns |
"prefix" |
Text value corresponding to the "label prefix" of the cell. Returns single quotation mark (') if the cell contains left-aligned text, double quotation mark (") if the cell contains right-aligned text, caret (^) if the cell contains centered text, backslash (\) if the cell contains fill-aligned text, and empty text ("") if the cell contains anything else. |
"protect" |
0 if the cell is not locked, and 1 if the cell is locked. |
"row" |
Row number of the 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" |
Column width of the cell rounded off to an integer. Each unit of column width is equal to the width of one character in the default font size. |
Reference is the cell that you want information about.
The following list describes the text values CELL returns when info_type is "format", and reference is a cell formatted with a built-in number format.
If the Microsoft Excel format is |
CELL returns |
General |
"G" |
0 |
"F0" |
#,##0 |
",0" |
0.00 |
"F2" |
#,##0.00 |
",2" |
$#,##0_);($#,##0) |
"C0' |
$#,##0_);[Red]($#,##0) |
"C0-" |
$#,##0.00_);($#,##0.00) |
"C2" |
$#,##0.00_);[Red]($#,##0.00) |
"C2-" |
0% |
"P0" |
0.00% |
"P2" |
0.00E+00 |
"S2" |
# ?/? or # ??/?? |
"G" |
m/d/yy or m/d/yy h:mm or mm/dd/yy |
"D4" |
d-mmm-yy or dd-mmm-yy |
"D1" |
d-mmm or dd-mmm |
"D2" |
mmm-yy |
"D3" |
mm/dd |
"D5" |
h:mm AM/PM |
"D7" |
h:mm:ss AM/PM |
"D6" |
h:mm |
"D9" |
h:mm:ss |
"D8" |
If the info_type argument in the CELL formula is "format", and if the cell is formatted later with a custom format, then you must recalculate the worksheet to update the CELL formula.
Remarks
The CELL function is provided for compatibility with other spreadsheet programs.
Examples
CELL("row",A20)
equals 20
If B12 has the format "d-mmm", then:
CELL("format",B12)
equals "D2"
If A3 contains TOTAL, then:
CELL("contents", A3)
equals "TOTAL"