The CELL function in Google Sheets is a powerful tool for retrieving metadata about a specific cell or range of cells. This function allows users to access various attributes, such as cell formatting, location, and formula, thus enhancing data management and analysis in spreadsheets.
Syntax
CELL(info_type, [reference])
- info_type: A text string specifying the type of information to return. For example, “address” or “format”.
- reference: An optional argument indicating the cell or range of cells to inspect. If omitted, it refers to the cell containing the formula itself.
Example #1
=CELL("address", A1)
This function returns the address of cell A1, which might be “$A$1” if the cell is located in that position.
Example #2
=CELL("format", A1)
This function retrieves the format code of cell A1. For example, it may return “D” if the cell is formatted as a date.
Example #3
=CELL("filename", B1)
This function provides the full path of the spreadsheet file that contains cell B1. An example result could be “C:\Users\User\Documents\spreadsheet.xlsx”.
Error handling
- VALUE!: This error occurs when the info_type parameter is invalid or not recognized by Google Sheets.
- REF!: This error appears when the specified reference is invalid or refers to a non-existent cell.
- NAME?: This error is triggered when the CELL function is not recognized, often due to a typo in the function name.