Description
Use this function to return information about the formatting, location, or contents of a cell.
This function can retrieve things such as address and filename, as well as detailed info about the formatting used in the cell. See below for a full list of information available.
Note: Formulas that use CELL have language-specific argument values and will return errors if calculated using a different language.
For example, if you create a formula containing CELL while using German, that formula will return an error if the workbook is opened using the French version. If it is important for others to open your workbook using different languages, consider either using alternative functions or allowing others to save local copies in which they revise the CELL arguments to match their language.
Syntax
CELL(info_type, [reference])
Inputs
This function has the following arguments:
| Name | Required | Description | Valid input |
|---|---|---|---|
info_type |
Yes | The information type to be considered. |
A text string that matches the list below in quotation marks, a cell reference, or a formula which results in a cell reference. Info typesThe following
|
reference |
Yes | The address for the cell containing the information. | A cell ID or a formula which results in a single cell ID. |
Note: The following Excel info_types are not supported: color, filename, format, parentheses, prefix, protect, row, width.
Example
Sample data
| A | B | C | |
|---|---|---|---|
| 1 | red | 56 | address |
| 2 | green | 39 | col |
| 3 | orange | 15 | contents |
| 4 | red | 92 | row |
| 5 | blue | 22 | type |
Sample formulas
| Use case | Formula | Explanation and Result |
|---|---|---|
| Determine if a cell contains a specific term. |
|
This formula works in the following manner:
For this data set, the first formula returns TRUE. This formula works in the following manner:
For this data set, the second formula returns FALSE. |
| Return the address of a specified cell. | =CELL("address", A2) |
This formula works in the following manner:
For this data set, this formula returns $A$2. |
| Return the column ID of a specified cell. | =CELL("col", B1) |
This formula works in the following manner:
For this data set, this formula returns 2 (because B is the second column). |
| Return the type of a specified cell. |
|
This formula works in the following manner:
For this data set, this formula returns l (label) This formula works in the following manner:
For this data set, this formula returns v (value) |
| Return the contents of a specified cell. | =CELL("contents", A1) |
This formula works in the following manner:
For this data set, this formula returns red. |
Return the address of a specified cell using the contents of another cell as a reference for the info_type value. |
=CELL(C1,B1) |
This formula works in the following manner:
For this data set, this formula returns $B$1. |
| Determine the content type for a cell, and return a specified string identifying the type. | =IFS(CELL("type",B1)="l","Text", CELL("type",B1)="v", "Number",CELL("type",B1)="b", "Empty",TRUE,"Other") |
This formula works in the following manner:
For this data set, this formula returns Number (because CELL returned "v"). |
Notes
- CELL can only apply to a single cell.
- CELL is a volatile function and may cause performance issues in large or complex worksheets.
- Wildcards do not work with this function.
- CELL returns information as a text value, regardless of the type of information requested.
Tips
- Use CELL to gather information about cell formatting and contents for dynamic reporting.
- Use CELL in conditional formatting (Example: setting
=CELL("type",B1)="b"as the condition formula will apply the specified formatting to all text cells included in the conditional range. Note that B1 does not need to have a text type.) - You can combine CELL with functions such as IF or ISNUMBER for conditional formatting and validation.
- CELL is useful for auditing and troubleshooting your worksheets.