Skip to content

FORMULATEXT

Returns the formula in a cell as text, exactly as it appears in the formula bar. Use it to document a model or to show a formula beside its result.

Syntax

=FORMULATEXT()

Lookup and reference

Excel 2013 and later, including Microsoft 365, Excel 2024, 2021, 2019 and 2016, Excel for the web and the mobile apps. Not available in Excel 2010 or earlier.

Try it

Edit the formula in C2 or change the inputs. The sheet recalculates as you type.

C2
A
B
C
D
1
Net price
Price with tax
Formula used
2
50
60
=A2*1.2
3
4

C2 =FORMULATEXT(B2) returns =A2*1.2

How FORMULATEXT works

FORMULATEXT shows the formula in a cell as text. If B2 contains =A2*1.2, then =FORMULATEXT(B2) in another cell returns the text =A2*1.2. It is the tidy way to show a formula next to its result in a worked example, a handover note, a model-review sheet or a training document.

The argument

reference is the cell to read. Use a single cell. The result is the formula as Excel would show it in the formula bar, starting with the equals sign.

  • If the cell holds a constant, an empty value or text, FORMULATEXT returns #N/A.
  • If the cell's formula is hidden by sheet protection, it returns #N/A.
  • If the reference points at a cell in a closed workbook, it returns #N/A.

A better way than the apostrophe trick

Before FORMULATEXT, people showed formulas by putting an apostrophe in front, which turned the formula into text and stopped it calculating. FORMULATEXT is better: the real formula keeps calculating in its own cell, and the text display is a separate, live cell. If the formula changes, the text changes with it.

Handling cells with no formula

Because a plain value returns #N/A, wrap the call when you point it at a mixed range: =IFERROR(FORMULATEXT(B2), "No formula"). IFERROR hides every error, and FORMULATEXT can only return #N/A in this situation, so IFNA is the narrower choice. In Excel 2013 and later, you can also test with ISFORMULA(B2) first.

Uses

  • Documentation. Place the result and its formula side by side so readers see how a number was built.
  • Auditing. A column of FORMULATEXT results alongside a column of numbers makes inconsistent formulas easy to spot. If one row in a filled column has a different shape, it stands out.
  • Teaching. Show a worked example live. Change the input and the result changes, while the formula text stays the same.
  • Comparing versions. Put FORMULATEXT on both copies and compare cell by cell with an equals test.

Limits

FORMULATEXT returns the formula as written, with the references as they currently stand. Copying the FORMULATEXT cell down a column doesn't copy the formula it reads, because the text is just text: the reference inside FORMULATEXT is what shifts, so FORMULATEXT(B2) becomes FORMULATEXT(B3). If you need to run the formula text as a calculation, you can't: INDIRECT turns text into a reference, not into a calculation, so the text is for display only.

A formula longer than 8,192 characters returns #N/A.

Arguments

reference
The cell that holds the formula you want to read, such as B2. If you give a range, FORMULATEXT uses its top-left cell. If the cell has no formula, the result is #N/A.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Show the formula beside its result

C2 =FORMULATEXT(B2)

Result: =A2*1.2

FORMULATEXT returns the formula in B2 as text, including the equals sign. B2 keeps calculating as normal.

C2
A
B
C
D
1
Net price
Price with tax
Formula used
2
50
60
=A2*1.2
3
4

C2 =FORMULATEXT(B2) returns =A2*1.2

Example 2

A function with a range

D2 =FORMULATEXT(B5)

Result: =SUM(B2:B4)

The result is the formula text, not the total. The total, 1,257, stays in B5.

D2
A
B
C
D
1
Month
Units
Formula in B5
2
Jan
410
=SUM(B2:B4)
3
Feb
385
4
Mar
462
5
Total
1257
6
7

D2 =FORMULATEXT(B5) returns =SUM(B2:B4)

Example 3

A cell with no formula returns #N/A

C2 =FORMULATEXT(B2)

Result: #N/A

B2 holds the typed number 60, not a formula, so FORMULATEXT has nothing to return.

C2
A
B
C
D
1
Net price
Typed price with tax
Formula used
2
50
60
#N/A
3
4

C2 =FORMULATEXT(B2) returns #N/A

Example 4

Show a message instead of #N/A

C2 =IFNA(FORMULATEXT(B2),"No formula")

Result: No formula

IFNA catches the #N/A and shows your text. It is a better choice here than IFERROR, because it leaves any other error visible.

C2
A
B
C
D
1
Net price
Typed price with tax
Formula used
2
50
60
No formula
3
4

C2 =IFNA(FORMULATEXT(B2),"No formula") returns No formula

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In C2, show the formula in B2 as text. Fill down to C4.

Answer in C2, then it fills down to C4.

C2
A
B
C
D
E
1
Net price
Price with tax
Formula used
2
50
60
3
80
96
4
120
144
5
6
Price
Note
7
60
8

Common mistakes

  • A cell without a formula returns #N/A, not an empty result. Wrap the call in IFNA when the range mixes typed values and formulas.
  • If the formula cells are protected with the Hidden option and the sheet is protected, FORMULATEXT returns #N/A. That is by design.
  • FORMULATEXT is text, so it can't be calculated. It is for display and documentation only.
  • Filling the FORMULATEXT cell down shifts its reference as well, which is usually what you want, but check the first and last rows.
  • FORMULATEXT isn't available in Excel 2010 or earlier, where it returns #NAME?.

Questions people ask

How do I show a formula as text in another cell?

Use FORMULATEXT: `=FORMULATEXT(B2)` returns the formula in B2 as text. Don't use an apostrophe in front of the formula, because that stops it calculating.

Why does FORMULATEXT return #N/A?

The referenced cell has no formula, the formula is hidden by sheet protection, or the cell is in a closed workbook. A plain number, text or empty cell always returns #N/A.

How can I see all formulas on a sheet at once?

Press Ctrl+` (the grave accent key) to show formulas instead of results, or use Show Formulas on the Formulas tab. Use FORMULATEXT when you want the formulas in cells of their own.

Does FORMULATEXT work in older versions of Excel?

It was added in Excel 2013. In Excel 2010 and earlier it returns #NAME?.

Learn FORMULATEXT in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.