How to use CELL Function in Excel

The Excel CELL function returns information about a cell in a worksheet. The type of information to be returned is specified as info_type. CELL can get things like address and filename, as well as detailed info about the formatting used in the cell. See below for a full list of information available.

Syntax:= CELL (info_type, [reference])

The CELL function syntax has the following arguments:

  • info_type:Required

A text value that specifies what type of cell information you want to return. The following list shows the possible values of the Info_type argument and the corresponding results.

  • reference: Optional

The cell that you want information about. If omitted, the information specified in the info_type argument is returned for the last cell that was changed. If the reference argument is a range of cells, the CELL function returns the information for only the upper left cell of the range.

The following list describes the text values that can be used for the info_type argument. These values must be entered in the CELL function with quotes (” “).

info_type Returns
“address” Reference of the first cell in reference, as text.
“col” Column number of the cell in reference.
“color” The value 1 if the cell is formatted in color for negative values; otherwise returns 0 (zero).

Note: This value is not supported in Excel for the web, Excel Mobile, and Excel Starter.

“contents” Value of the upper-left cell in reference; not a formula.
“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.

Note: This value is not supported in Excel for the web, Excel Mobile, and Excel Starter.

“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.

Note: This value is not supported in Excel for the web, Excel Mobile, and Excel Starter.

“parentheses” The value 1 if the cell is formatted with parentheses for positive or all values; otherwise returns 0.

Note: This value is not supported in Excel for the web, Excel Mobile, and Excel Starter.

“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.

Note: This value is not supported in Excel for the web, Excel Mobile, and Excel Starter.

“protect” The value 0 if the cell is not locked; otherwise returns 1 if the cell is locked.

Note: This value is not supported in Excel for the web, Excel Mobile, and Excel Starter.

“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” Returns an array with 2 items.

The 1st item in the array is the 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.

The 2nd item in the array is a Boolean value, the value is TRUE if the column width is the default or FALSE if the width has been explicitly set by the user.

Note: This value is not supported in Excel for the web, Excel Mobile, and Excel Starter.

CELL format codes

The following list describes the text values that the CELL function returns when the Info_type argument is “format” and the reference argument is a cell that is formatted with a built-in number format.

If the Excel format is The CELL function 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”

Example: Let’s look at some Excel CELL function examples and explore how to use the CELL function as a worksheet function in Microsoft Excel:

Syntax:  =CELL(B2,A2)

Result:

Based on the Excel spreadsheet above, the following CELL examples would return:

Syntax: =CELL(B3,A3)
Result: 1

Syntax: =CELL(B4,A4)
Result: 0

Syntax: =CELL(B5,A5)
Result: Friday

Syntax: =CELL(B6,A6)
Result: G

Syntax: =CELL(B7,A7)
Result: 0

Syntax: =CELL(B8,A8)
Result:

Syntax: =CELL(B9,A9)
Result: 1

Syntax: =CELL(B10,A10)
Result: 10

Syntax: =CELL(B11,A11)
Result: l

Syntax: =CELL(B12,A12)
Result: 16

Note:

  1. #VALUE! error – Occurs when the given info_type argument is not one of the recognized types.
    • The given index_num is less than 1 or is greater than the given number of values.
    • The given index_num argument is non-numeric.
  1. #NAME? error – Occurs when the value arguments are text values that are not enclosed in quotes and are not valid cell references.

Add a Comment

Your email address will not be published. Required fields are marked *