This function evaluates information about the formatting, location, or contents of a cell.
CELL(info, reference)
This function has the following arguments:
Argument | Description |
---|---|
info | Refers to a text value that specifies what type of cell information to return. This argument is required. |
reference | Refers to the cell to get information about. This argument is optional. |
The info argument has the following options.
Option | Returns |
---|---|
address | The first cell reference, as text. |
col | The column number of the cell. |
color | The value 1 if the cell is formatted in color for negative values; otherwise, returns 0 (zero). |
contents | The value of the upper-left cell in the reference. |
filename | A filename (including full path) of the file that contains the reference. |
format | A text value that corresponds to the number format of the cell (as shown in the following table). |
parentheses | The value 1 if the cell is formatted with parentheses for positive or all values; otherwise, returns 0. |
prefix | A text value that corresponds to the label prefix for the cell. If the cell contains left-aligned text, a single quotation mark (') is returned. If the cell contains right-aligned text, a double quotation mark (") is returned. If the text is centered, a caret (^) is returned. A backslash (\) is returned if the text is fill aligned and empty text is returned if the cell contains anything else. |
protect | The value 0 is returned if the cell is not locked and 1 is returned if the cell is locked. |
row | The row number of the cell. |
type | A text value that corresponds to the type of data in the cell ("b" if empty, "i" if the cell contains a text constant, and "v" if the cell contains anything else). |
width | The column width of the cell. |
The following items are returned when using the format option.
Format | 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 reference argument is a range of cells, this function only returns information for the upper left cell of the range.
Accepts string or numeric data. Returns numeric or string data.
CELL("row", A10) gives the result 10 (10 is the number of cell A10).
CELL("type", B5) returns the data type of the information contained in the cell B5.
This function is available in Spread for Windows Forms 11.0 or later.