CELL Function in☝️ Google Sheets Explained (Definition, Syntax, How to Use It, Examples)

This guide covers everything you need to know about the Google Sheets CELL function, including its definition, syntax, use cases, and how to use it.

What is the CELL Function? How Does It Work?

The CELL function in Google Sheets is a handy tool that gives you various details about a specific cell. You can learn about a cell’s location, its content, how it’s formatted, and even its size. To decide what kind of detail you want, you provide an ‘info_type’ value when using the function.

For instance, by using the “address” info_type with the CELL function, you get the exact location of the cell in text form. On the other hand, with “col”, you get the cell’s column number. If you’re interested in the cell’s color, particularly if it’s red for negative numbers, the “color” info_type will give you a value of 1; otherwise, you get a 0.

If you need the actual content of a cell, use the “contents” info_type. The “prefix” info_type tells you about the text alignment of the cell by giving you a specific symbol for each alignment type.

To find out the row number of a cell, use the “row” info_type. If you’re curious about the kind of data in the cell, the “type” info_type will tell you. It gives you “b” for empty cells, “l” for text-only cells, and “v” for all other cells.

And if you’re trying to understand the size of a column, the “width” info_type tells you how many characters can fit in the cell you’re referring to.

CELL Syntax

The syntax and arguments for the function are as follows:

CELL(info_type, reference)

Here are the details for each argument:

  • info_type: This argument specifies the type of information you wish to retrieve about the cell.
  • reference: This argument refers to the cell for which you want to obtain information.

Notes on the arguments:

  • The info_type argument can take several values, each of which returns a different type of information about the cell:
    • “address”: This returns the absolute reference of the top left cell in the reference as plain text.
    • “col”: This returns the column number of the cell in the reference.
    • “color”: This returns 1 if the top left cell in the reference is formatted in red for negative values, such as when the custom number format is #,##0_);[Red](#,##0). Otherwise, it returns 0.
    • “contents”: This returns the value contained in the top left cell in the reference.
    • “prefix”: This returns a text value based on the horizontal text alignment in the cell in the reference. A single quotation mark (‘) is used for left-aligned text, a double quotation mark (“) for right-aligned text, a carat (^) for centered text, and empty for everything else.
    • “row”: This returns the row number of the top left cell in the reference.
    • “type”: This returns the type of data in the cell in the reference. It returns “b” for a blank cell, “l” for a cell containing plain text (label), and “v” for a cell containing any other type of data (value).
    • “width”: This returns the column width in terms of the number of characters that can fit in the cell in the reference. The number returned is based on the width of the zero (0) character at the default font size. This is different from the cell width used elsewhere in Google Sheets, which is defined in terms of pixels.

Examples of How to Use the CELL Function

Here are some practical examples of how to use the CELL function in Google Sheets.

Example #1: Get Cell Address

If you want to get the address of a particular cell, you can use the CELL function. Let’s say you want to get the address of cell B5. You would type the following formula:

=CELL(“address”, B5)

The result would be “$B$5”, which is the address of the cell.

Example #2: Get Cell Content

The CELL function can also be used to get the content of a specific cell. For instance, if you want to get the content of cell D6, you would use the following formula:

=CELL(“contents”, D6)

This will return the value that is in cell D6.

Example #3: Get Cell Format

The CELL function can also provide information about the formatting of a cell. For example, if you want to know if cell E7 is formatted as a date, you would use the following formula:

=CELL(“format”, E7)

If the cell is formatted as a date, the function will return “D1”, “D2”, “D3”, or “D4”, depending on the exact date format. If the cell is not formatted as a date, the function will return a different code.

Example #4: Get Cell Width

If you want to know the width of a cell, you can use the CELL function. For instance, to get the width of cell F8, you would use the following formula:

=CELL(“width”, F8)

This will return the width of the cell in characters based on the default font size.

Example #5: Get Cell Type

The CELL function can also be used to determine if a cell contains a number, a text string, or is blank. For example, to find out the type of content in cell G9, you would use the following formula:

=CELL(“type”, G9)

This will return “b” if the cell is blank, “l” if the cell contains a text string, or “v” if the cell contains anything else.

Why Is CELL Not Working? Troubleshooting Common Errors

If you encounter issues while using the CELL function in Google Sheets, it’s important to understand the common errors that can occur, their causes, and how to fix them.

#VALUE! Error

Cause: The #VALUE! error is one of the most common errors that Google Sheets users encounter while using the CELL function. This error occurs when the input argument or the formula syntax is incorrect. For example, if you’re trying to retrieve information about a specific cell but the cell reference is missing or not recognized, Google Sheets will return a #VALUE! error.

Solution: To fix a #VALUE! error, review the syntax of your formula to make sure it’s correct. Verify that all required arguments are included and that cell references are valid. If you’re referencing cells in a different sheet, make sure the sheet name is correct and properly formatted with single quotes.

#REF! Error

Cause: The #REF! error appears when a formula refers to a cell that’s not valid. This can happen if you’ve deleted a cell that was being referenced in your formula.

Solution: To solve the #REF! error, identify the cell the formula is trying to reference, and make sure it exists. If you’ve deleted a cell being used in your formula, you’ll need to adjust or undo the deletion.

#N/A Error

Cause: The #N/A error shows up when the CELL function cannot find the information it’s trying to retrieve. This may happen if you’re trying to use the CELL function to retrieve information that doesn’t exist. For example, if you’re trying to retrieve the cell address of a named range, but the named range doesn’t exist, Google Sheets will return a #N/A error.

Solution: To fix the #N/A error, confirm that the information you’re trying to retrieve with the CELL function exists. If you’re trying to retrieve information about a named range, make sure the named range exists and is spelled correctly.

#NUM! Error

Cause: The #NUM! error is triggered when the CELL function encounters an invalid numeric value. This typically occurs when the formula expects a number but receives a different data type, such as text.

Solution: To correct the #NUM! error, ensure that all numeric values in your formula are valid. If a cell reference is supposed to contain a number, ensure it does. If you manually enter a number into your formula, check to see if it’s entered correctly.

By understanding these common errors and their causes, you can effectively troubleshoot issues that arise when using the CELL function in Google Sheets. With these solutions, you can ensure the accuracy and efficiency of your data analysis and manipulation tasks.

Using CELL With Other Google Sheets Functions

Combining the CELL function with other Google Sheets functions can greatly enhance your data analysis and reporting capabilities. The CELL function can be used with a variety of other functions to provide more complex and detailed information. Here are some examples of how the CELL function can be used with other Google Sheets functions:

With COUNTIF

Usage: The COUNTIF function counts the number of cells within a range that meet the given condition. This can be combined with the CELL function to provide more detailed analysis.

Example: Suppose you want to count how many cells in a range have a specific format. You could use the CELL function to get the format of a cell and the COUNTIF function to count cells with that format. The formula would look something like this:

=COUNTIF(A1:A10, CELL(“format”, A1))

This formula counts the number of cells in the range A1:A10 that have the same format as cell A1.

With IF

Usage: The IF function is used to make logical comparisons between a value and what you expect. When combined with the CELL function, it can provide useful insights.

Example: Suppose you want to check if a cell contains a date. You could use the CELL function to get the format of a cell and the IF function to check if it’s a date. The formula would look something like this:

=IF(CELL(“format”, A1) = “D1”, “Yes”, “No”)

This formula checks if the format of cell A1 is a date. If it is, it returns “Yes”; if it’s not, it returns “No”.

With CONCATENATE

Usage: The CONCATENATE function joins two or more text strings into one text string. It can be combined with the CELL function to create custom messages.

Example: Suppose you want to create a custom message that includes the address of a cell. You could use the CELL function to get the address of a cell and the CONCATENATE function to create the message. The formula would look something like this:

=CONCATENATE(“The address of the selected cell is “, CELL(“address”, A1))

This formula creates a message that includes the address of cell A1.

For more details on the CELL function, check out the official documentation at the Google Docs Editors Help Center.

More Google Sheets Tutorials
More Microsoft Excel Tutorials
Share This Post
Daniel Smith
Daniel Smith
Daniel Smith is automation consultant with a passion for technology, data, AI, and machine learning.

The Spreadsheet Daddy add-on rebrands to Synterrix. Click here to learn more.

X