🚀The world's best VBA AI has evolved. ExcelMaster is now an autonomous Agent.Read more →
Back to Blog

Excel CELL Function — Get a Cell's Address, Format, Type, and Filename

|

Excel CELL Function — Get a Cell's Address, Format, Type, and Filename

TL;DRCELL(info_type, [reference]) returns metadata about a cell — its address, format code, content type, column width, or the workbook's full path and sheet name — rather than the value inside it. You pick what to ask with a keyword string ("address", "filename", "format", "type", "col", …). In modern Excel most of its jobs have cleaner replacements — but CELL("filename",A1) is still the only native, non-VBA way to grab the current file path and sheet name.

=CELL("address", C5)      ' -> $C$5   (absolute address as text)
=CELL("filename", A1)     ' -> C:\Reports\[Sales.xlsx]January   (path + sheet)
=CELL("type", A1)         ' -> "b" blank, "l" label/text, or "v" value
=CELL("col", C5)          ' -> 3      (column number)

Where most functions reach inside a cell for its value, CELL walks around the cell and reports on its surroundings — where it lives, how it's formatted, what kind of thing it holds, and which file it's in. It's a metadata probe, and knowing its one durable use (and its one nasty trap) is most of what you need.

What you'll learn

  • The mental model: CELL is a metadata probe, not a value reader
  • Why info_type is a keyword string — and what happens when you misspell it
  • The job CELL still owns: extracting the filename, path, and sheet name
  • Why "format" returns a cryptic code, and why it goes stale
  • The recalculation trap that makes CELL "return the wrong thing"

The mental model: a metadata probe

Every other function you've met returns what's in a cell — its number, its text, the result of its formula. CELL is the exception: it returns facts about the cell. You tell it which fact you want with the first argument, info_type, and it points at a cell with the second:

=CELL("row", C5)     ' -> 5    which row is this cell in?
=CELL("width", C5)   ' -> 8    how wide is its column?

That first argument is the whole story. "address" gives you the absolute address as text; "row" and "col" give the coordinates as numbers; "contents" gives the value; "type" classifies what's inside; "format" reports the number format; "filename" returns the workbook path and sheet; "width" measures the column. It's the same family idea as COUNTIF's criteria being a string — the behavior is driven by a bit of text you hand in, so a typo doesn't error the way a wrong number would; =CELL("adress", C5) (misspelled) returns #VALUE!.

The job CELL still owns: filename, path, and sheet name

Here is the reason CELL survives in modern workbooks. CELL("filename", …) is the only built-in way, short of VBA, to read the workbook's own path and the current sheet name:

=CELL("filename", A1)
' -> C:\Reports\[Sales.xlsx]January

You rarely want the whole string — you want a piece of it, so you carve it out with text functions. The sheet name (everything after the ]) is the common ask:

=MID(CELL("filename",A1), FIND("]",CELL("filename",A1))+1, 255)
' -> January   (the sheet name alone)

Two traps live in that one call, and both are easy to miss:

  • Pass the reference. CELL("filename") with no second argument technically works, but it reports on the last cell that changed anywhere, which drifts as you edit. Always pin it: CELL("filename", A1).
  • Save the file first. On a workbook that has never been saved, there is no path yet, so CELL("filename",A1) returns an empty string — not an error, just blank. Analysts chasing "why is my sheet-name formula empty?" have almost always hit an unsaved file.

Why "format" returns a cryptic code (and goes stale)

CELL("format", …) sounds useful — "tell me how this cell is formatted" — but it's the info_type that disappoints most often. It returns a short code, not the format string you see in the dialog: "C2" for currency with two decimals, "P0" for a percentage with none, "D1" for one of the date styles, "G" for General.

Two problems follow. First, the codes are a lossy, cryptic mapping — many custom formats collapse to the same code, and the lookup is region-dependent, so branching your logic on CELL("format",…) is fragile. Second, and worse: "format" reads the format, not the value, and changing a cell's format doesn't trigger a recalculation. So after you reformat a cell, the CELL result keeps showing the old code until something forces a recalc (F9). That "it's showing the wrong format" confusion is nearly always a stale-calc issue, not a bug — and it's why using "format" to drive formulas is a trap best avoided.

The recalculation and volatility trap

The staleness above is worth stating as its own rule, because it burns people beyond just "format". CELL is a volatile function — it recalculates on every sheet change, which quietly slows big workbooks if you scatter it around. Yet paradoxically, the specific facts it reports (especially format and color) update only on a recalc, and a formatting change alone isn't one. The mental model to keep: CELL tells you the truth as of the last recalculation, not as of this instant. When in doubt, press F9 before you trust a "format" or "color" read.

The judgment call

CELL is a Swiss-army knife where most of the blades have been replaced by better single-purpose tools. Need the address? ADDRESS, or plain ROW/COLUMN, are clearer. Need to know the type? The IS functions (ISNUMBER, ISTEXT, ISBLANK) say what you mean — and note that CELL's "type" is coarse: it only distinguishes blank (b), label/text (l), and value (v), and a formula returning "" counts as a label, not blank. Need the value? Just reference the cell. What's left, and what keeps CELL in the toolbox, is "filename" — the path and sheet name have no cleaner native source. Its steady decline in use isn't a mystery; it's the sound of every other blade being retired while the one good one stays sharp.

How ExcelMaster helps

The CELL("filename",…) + MID + FIND combo to extract a sheet name is the kind of thing you look up every single time. Tell ExcelMaster "put the current sheet name in A1" or "show the workbook's folder path in the header," and it writes the nested formula correctly — pinned reference, save-state handled, the right slice of the path — so you don't rebuild it from memory. Ask it for a cell's format or type and it'll steer you to the sharper tool (IS functions, ADDRESS) when CELL would only give you a cryptic code.

Frequently asked questions

What does the CELL function do in Excel?

=CELL(info_type, [reference]) returns information about a cell rather than its value — such as its address, row, column, number-format code, content type, column width, or the workbook's filename. You choose what to return with the info_type keyword, for example =CELL("address", C5) to get $C$5.

How do I get the sheet name or file path in Excel?

Use =CELL("filename", A1), which returns the full path plus sheet name like C:\Reports\[Sales.xlsx]January. To isolate just the sheet name, wrap it: =MID(CELL("filename",A1), FIND("]",CELL("filename",A1))+1, 255). The workbook must be saved first, or the result is an empty string.

Why does CELL("format") show the wrong format?

Changing a cell's format doesn't trigger a recalculation, so CELL("format",…) keeps displaying the previous format code until Excel recalculates. Press F9 to force it. The result is also a short code ("C2", "P0", "G"), not the full format string — which is why branching logic on it is fragile.

What do the CELL "type" results b, l, and v mean?

"b" means the cell is blank, "l" means it holds a label (text), and "v" means it holds a value (a number or other non-text). It's a coarse check — a formula returning "" reads as l. For precise type tests use the IS functions like ISNUMBER and ISBLANK.

Is the CELL function volatile?

Yes. CELL recalculates on every worksheet change, so using it heavily can slow a large workbook. Prefer non-volatile alternatives — ADDRESS, ROW, COLUMN, or the IS functions — for everything except the filename/path use that CELL uniquely handles.

Tested in

Tested in: Excel 365 (Windows 11) — last verified 2026-07-09.

Related guides: Excel ADDRESS · Excel IS Functions · Excel FORMULATEXT & ISFORMULA · Excel TYPE & N