Most Excel functions work on values — they calculate, compare, or transform data. The CELL function works differently. Instead of returning a calculated result, it inspects a cell and reports metadata about it. Ask it for the file path and it tells you where the workbook is saved. Ask it for the format code and it tells you how a cell is formatted. Ask it for the data type and it tells you whether the cell holds a number, text, or is blank. Consequently, CELL bridges the gap between data and workbook information — all without leaving the formula bar.
What Is the CELL Syntax?
CELL takes two arguments — what to inspect and which cell to inspect.
| Argument | Required? | What it does |
|---|---|---|
| info_type | Required | A text string that specifies which type of information to return. Must be one of the predefined values in the table below. Always enclose in double quotes — for example, "filename" or "address". The argument is not case-sensitive. |
| reference | Optional | The cell to inspect. Defaults to the most recently changed cell if omitted. Always supply a reference explicitly — for example, A1 — to get predictable results. For file path and sheet name, any cell on the target sheet works. |
What Are All the CELL info_type Values?
CELL supports twelve predefined info_type values. They fall into four categories: path and location, cell address, data type, and formatting. The table below lists all twelve, grouped by category.
| Category | info_type value | What it returns |
|---|---|---|
| Path & location | "filename" | Full path, workbook name in [brackets], and sheet name — e.g. C:\Reports\[Budget.xlsx]Q1. Returns blank if the file is unsaved. |
| Location | "address" | Absolute cell address as text — e.g. $A$1. Uses $ signs for both row and column. |
| Location | "col" | Column number of the referenced cell — A=1, B=2, etc. |
| Location | "row" | Row number of the referenced cell. |
| Data type | "type" | "b" for blank, "l" for label (text), "v" for value (number or formula result). |
| Data type | "contents" | The value stored in the cell — for formulas, returns the formula's result rather than the formula text itself. |
| Data type | "protect" | 1 if the cell is locked, 0 if it is unlocked. |
| Formatting | "format" | A text code representing the number format — "G" for General, "D1" for Date, "P2" for Percentage with 2 decimal places, etc. |
| Formatting | "parentheses" | 1 if the format includes parentheses for negative numbers, 0 if not. |
| Formatting | "prefix" | Text-alignment prefix: ' for left, " for right, ^ for centre, \ for fill-aligned. Empty string for non-text cells. |
| Formatting | "color" | 1 if the format uses a different colour for negative values, 0 if not. |
| Formatting | "width" | Column width rounded to the nearest integer, in default font units. |
Example 1: Get the Full File Path and Workbook Name
The "filename" info_type returns the complete path, workbook name, and sheet name in one string. This is useful for audit trails and for reports that need to self-document their source location. The workbook must be saved first — unsaved files return a blank.
Example 2: Extract Just the Sheet Name
The "filename" string always ends with the sheet name after the "]" character. Extracting just the sheet name is therefore a matter of taking everything that follows the last "]". This is useful for dynamic titles and dashboard headings. Report headers that should update when a sheet is renamed benefit especially.
Example 3: Return a Cell's Absolute Address
The "address" info_type returns a cell reference as a text string — for example, $B$5. This differs from ADDRESS(), which constructs a reference from row and column numbers. CELL("address") inspects a live cell instead. Use CELL("address") to display where a formula is pointing. It is also useful for capturing a cell's address in an audit trail.
Example 4: Check Data Type with "type"
The "type" info_type returns a one-letter code for the content category: "b" for blank, "l" for label (text), and "v" for value (any number, date, or formula result). This lets you make formulas conditional on what a cell actually contains — independently of what it looks like.
Example 5: Inspect the Number Format with "format"
The "format" info_type returns a text code representing the number format applied to a cell. For example, "G" means General, "D1" means a short date format, and "P2" means Percentage with two decimal places. This is useful for detecting whether a cell is formatted as a date before performing date arithmetic. It also helps confirm that financial data is in the expected currency format.
Common Format Codes Returned by CELL
Format codes are not the same as custom format strings. Instead, they are a predefined set of short codes that CELL maps to common Excel formats. Additionally, the code changes when you apply a different format. However, you must press F9 to force recalculation — CELL does not update format codes automatically.
Example 6: Build a Self-Updating Report Header
Combining CELL info types produces a rich, self-documenting header. Stacking "filename", "address", and sheet name extraction produces a header that automatically reflects where the report lives. Consequently, printed copies become automatically traceable without any manual update. Consequently, printed copies become automatically traceable without any manual updating.
How to Fix Common CELL Function Issues
CELL("filename") returns a blank
The workbook has not been saved yet. CELL("filename") requires the file to have a path — an unsaved workbook has no path to display. Save the file with a name and the result appears immediately. Additionally, some Excel Online environments return a blank for "filename" regardless of save status.
CELL("format") does not update after a format change
Format changes do not always trigger recalculation for volatile functions. Press F9 to force a full recalculation after changing a cell's format. Alternatively, enter data in any other cell — this triggers recalculation and updates the format code.
#VALUE! error
The info_type argument is not one of the twelve predefined strings. Check the spelling carefully — for example, "filename" not "file name". Additionally, note that CELL is language-sensitive in some versions. If a workbook moves between language versions of Excel, the info_type strings may need updating to match the receiving version.
Frequently Asked Questions
-
What does the CELL function do in Excel?+CELL returns metadata about a specified cell — information about its location, content type, formatting, or the file it is in. The type of information is controlled by info_type — one of twelve predefined text strings such as "filename", "address", "type", or "format". The result updates automatically whenever the workbook recalculates, making it useful for dynamic headers, audit trails, and formula-driven documentation.
-
How do I get just the sheet name using CELL?+Use CELL("filename", A1) to get the full path string, then extract the sheet name from it. In Excel 2021 and later, use TEXTAFTER: =TEXTAFTER(CELL("filename",A1),"]"). In older versions, use MID and FIND: =MID(CELL("filename",A1), FIND("]",CELL("filename",A1))+1, 255). Both formulas return everything after the "]" character, which is always the sheet name. The workbook must be saved before CELL("filename") returns a result.
-
Why does CELL("filename") return a blank?+The workbook has not been saved yet. CELL("filename") needs a file path to work — an unsaved workbook has no path to display. Save the workbook to any location, and the formula will immediately return the full path, workbook name, and sheet name. Wrap the formula in IFERROR to handle unsaved files gracefully: =IFERROR(MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255), "Save file first").
More Questions About the CELL Function
-
What is the difference between CELL("type") and ISNUMBER?+CELL("type") returns a three-way code: "b" for blank, "l" for text, and "v" for any numeric value or formula result. ISNUMBER, by contrast, checks precisely whether a value is a genuine number. It returns FALSE for text strings even when they look like numbers. Use CELL("type") when you need to distinguish blank, text, and numeric content. Use ISNUMBER when you need precise numeric type checking, for example to guard arithmetic formulas.
-
Is CELL a volatile function?+Yes. CELL recalculates every time any cell in the workbook changes — even cells unrelated to the one being inspected. This is the same behaviour as NOW(), TODAY(), and RAND(). In large workbooks with many CELL formulas, this volatility can slow down calculation. To reduce the impact, use CELL sparingly. Lock results as static values when they are no longer needed, or switch to manual calculation mode during heavy data entry.
-
Which Excel versions support CELL?+CELL works in every Excel version from Excel 2000 onwards, including Microsoft 365, Excel 2024, 2021, 2019, and 2016. The basic info types work in all versions. The newer parsing approaches using TEXTBEFORE and TEXTAFTER require Excel 2021 or Microsoft 365. For Excel 2019 and earlier, use MID and FIND as the equivalent parsing approach.