CELL function

This article describes the formula syntax and usage of the CELLfunction in Microsoft Office Excel. Find links to more information about formatting the data in cells and applying cell styles in the See Also section.


The CELL function returns information about the formatting, location, or contents of a cell. For example, if you want to verify that a cell contains a numeric value instead of text before you perform a calculation on it, you can use the following formula:

=IF(CELL("type", A1) = "v", A1 * 2, 0)

This formula calculates A1*2 only if cell A1 contains a numeric value, and returns 0 if A1 contains text or is blank.


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 of the first cell in reference, as text.


Column number of the cell in reference.


The value 1 if the cell is formatted in color for negative values; otherwise returns 0 (zero).


Value of the upper-left cell in reference; not a formula.


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.


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.


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


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.


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


Row number of the cell in reference.


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.


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

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

























# ?/? or # ??/??


m/d/yy or m/d/yy h:mm or mm/dd/yy


d-mmm-yy or dd-mmm-yy


d-mmm or dd-mmm






h:mm AM/PM


h:mm:ss AM/PM






Note   If the info_type argument in the CELL function is "format" and you later apply a different format to the referenced cell, you must recalculate the worksheet to update the results of the CELL function.


The example may be easier to understand if you copy it to a blank worksheet.

How do I copy an example?

  1. Select the example in this article.

    Important   Do not select the row or column headers.

    selecting an example from help

    Selecting an example from Help

  2. Press CTRL+C.

  3. In Excel, create a blank workbook or worksheet.

  4. In the worksheet, select cell A1, and press CTRL+V.

    Important   For the example to work properly, you must paste it into cell A1 of the worksheet.

  5. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

After you copy the example to a blank worksheet, you can adapt it to suit your needs.


















=CELL("row", A20)

The row number of cell A20


=CELL("format", A2)

The format code of cell A2

D2 (d-mmm)

=CELL("contents", A3)

The content of cell A3


=CELL("type", A2)

The data type of cell A2

v (value)

Applies To: Excel 2007

Was this information helpful?

Yes No

How can we improve it?

255 characters remaining

To protect your privacy, please do not include contact information in your feedback. Review our privacy policy.

Thank you for your feedback!

Support resources

Change language