CELL Function: Get File Path, Address & Format Information in Excel

CELL Function IN EXCEL Feature Image
Learn how to use Excel’s CELL function to extract the file path, sheet name, cell address, data type, and format code. Covers all 12 info_type values with practical examples

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.

Availability: CELL works in every Excel version from Excel 2000 onwards, including Microsoft 365, Excel 2024, 2021, 2019, and 2016. It also works in Excel for the web, though the "filename" info_type returns a blank in some online environments.

What Is the CELL Syntax?

CELL takes two arguments — what to inspect and which cell to inspect.

=CELL(info_type, [reference])
ArgumentRequired?What it does
info_typeRequiredA 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.
referenceOptionalThe 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.

Categoryinfo_type valueWhat 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.
CELL is volatile — it recalculates on every change: Like NOW() and TODAY(), CELL recalculates every time any cell in the workbook changes. In large workbooks this can slow down calculation. To avoid performance issues, use CELL sparingly and lock results as static values once they are no longer needed.

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.

1
Return the full path, extract just the path folder, and extract just the filename
Formula
Result example
=CELL("filename",A1)
C:\Reports\[Budget.xlsx]Q1
=TEXTBEFORE(CELL("filename",A1),"[")
C:\Reports\ (path only)
=TEXTAFTER(TEXTBEFORE(CELL("filename",A1),"]"),"[")
Budget.xlsx (filename only)
Full path — includes folder, workbook name in [brackets], and sheet name: =CELL("filename", A1) requires the file to be saved first. =CELL("filename", A1) → C:\Reports\[Budget.xlsx]Q1 Extract path only — everything before the "[" (Excel 2021+ / 365): TEXTBEFORE returns all text before the first "[" character. =TEXTBEFORE(=CELL("filename", A1), "[") → C:\Reports\ Path only — older Excel compatible formula using SUBSTITUTE and FIND: =SUBSTITUTE(=CELL("filename",A1), RIGHT(=CELL("filename",A1), LEN(=CELL("filename",A1))- FIND("[",=CELL("filename",A1))+1),"") Extract workbook filename only (between "[" and "]"): TEXTAFTER gets text after "[", then TEXTBEFORE removes the sheet name after "]". =TEXTAFTER(TEXTBEFORE(=CELL("filename",A1),"]"),"[") → Budget.xlsx
Always pass a cell reference as the second argument — for example, A1. Without a reference, CELL("filename") uses the most recently active sheet. That may not be the sheet your formula lives on. This is a common source of unexpected results in multi-sheet workbooks.

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.

2
Display the current sheet name in a cell — updates automatically when renamed
Sheet name is everything after the "]" in the CELL("filename") result. Excel 2021+ / 365 — use TEXTAFTER for the cleanest formula: =TEXTAFTER(=CELL("filename", A1), "]") → Q1 (or whatever the sheet is named) All Excel versions — use MID and FIND instead: FIND locates "]"; MID extracts everything after it to end of string. =MID(=CELL("filename", A1), FIND("]", =CELL("filename", A1))+1, 255) Use IFERROR to handle unsaved workbooks gracefully: CELL returns blank for unsaved files, which makes MID error out. =IFERROR( MID(=CELL("filename", A1), FIND("]", =CELL("filename", A1))+1, 255), "Save file first") Build a dynamic title using the sheet name: Concatenate the sheet name with a label to create a self-updating heading. "Report: " & MID(=CELL("filename",A1),FIND("]",=CELL("filename",A1))+1,255) → Report: Q1
Rename a sheet and the formula updates automatically: CELL is volatile, so it recalculates whenever the workbook changes. Renaming the sheet — or any change to any cell — triggers a recalculation. Consequently, the sheet name formula always reflects the current tab name without any manual update.

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.

3
Get the address of a specific cell and use it in a dynamic label
Return the absolute address of cell B5 as a text string: =CELL("address", B5) → $B$5 Use in a label — show which cell a formula references: Useful for self-documenting audit sheets or formula inventory pages. "Data source: " & =CELL("address", B5) → Data source: $B$5 Capture the address of the cell containing the MAX value in a range. INDEX(range, MATCH(MAX...)) returns the max value; CELL wraps around it. =CELL("address", INDEX(B2:B100, MATCH(MAX(B2:B100), B2:B100, 0))) → $B$7 (the address of the highest value, wherever it is) Row and column number of a specific cell — useful for dynamic range building: =CELL("row", B5) → 5 =CELL("col", B5) → 2 (B is the 2nd column)

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.

4
Return a readable label based on cell content type — blank, text, or value
A — Contents
CELL("type",A)
Meaning
IF label formula
(empty)
b
Blank
Empty
"London"
l
Label (text)
Text
1,250
v
Value (number/formula)
Value
Check what type of content A2 holds — returns "b", "l", or "v": =CELL("type", A2) Convert the code to a readable label: =SWITCH(=CELL("type", A2), "b", "Empty", "l", "Text", "v", "Value") Guard a calculation — multiply only when A2 holds a value, not text: CELL("type") = "v" confirms A2 is numeric before proceeding. =IF(=CELL("type", A2)="v", A2 * 1.2, "Enter a number") Note — "type" vs ISNUMBER and ISTEXT: CELL("type","v") returns "v" for both numbers AND formula results. ISNUMBER checks the value type more precisely. Use ISNUMBER/ISTEXT when you need exact type checking. Use CELL("type") when you need the three-way blank/text/value distinction.

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.

5
Detect cell format codes and guard against date/number confusion
Applied format
CELL("format",A) returns
Notes
General
G
Default — no specific format
Number (0 dec.)
F0
F = Fixed, 0 = decimal places
Date (dd-mmm-yy)
D2
D = Date format variant
Percentage (2 dec.)
P2
P = Percentage, 2 = decimal places
Currency (£, 2 dec.)
C2
C = Currency
Return the format code for cell A2: =CELL("format", A2) Detect whether A2 is formatted as a date (codes start with "D"): LEFT extracts the first character; compare to "D". =IF(LEFT(=CELL("format", A2))="D", "Date cell", "Not a date") Detect whether the format includes negative-number colour coding: CELL("color") returns 1 if the format highlights negatives in colour. =CELL("color", A2) → 1 if the format colours negative numbers, 0 if not IMPORTANT — press F9 after changing a cell's format: CELL("format") does not automatically detect format changes. Pressing F9 forces recalculation and updates the format code.

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.

6
Assemble a dynamic report header — path, sheet name, and last modified info
Full filename string for reference (shows path + [workbook] + Sheet): =CELL("filename", A1) → C:\Reports\[Budget.xlsx]Q1 Sheet name only (for use in a report title): Works in all versions — extracts text after the last "]". =MID(=CELL("filename",A1), FIND("]",=CELL("filename",A1))+1, 255) → Q1 Workbook name only (between "[" and "]"): =MID(=CELL("filename",A1), FIND("[",=CELL("filename",A1))+1, FIND("]",=CELL("filename",A1)) - FIND("[",=CELL("filename",A1))-1) → Budget.xlsx Self-updating report header combining all three parts: Displays "Report: Q1 — Source: Budget.xlsx — Printed: 05-Apr-2026" "Report: " & MID(...sheetname...) & " — Source: " & MID(...workbookname...) & " — Printed: " & TEXT(TODAY(), "dd-mmm-yyyy")
Place the header formula in a merged cell at the top of the report. Each time the file opens, the date refreshes via TODAY(). The sheet and workbook names update via CELL automatically. No manual editing is ever needed to keep the header accurate.

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.

CELL without a reference can return unexpected results: When reference is omitted, CELL returns information about the "last changed cell" — which can be any cell in any open workbook. Consequently, always pass an explicit reference such as A1 to anchor the result to a specific cell and sheet.

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.