Lookup and reference functions

FORMULATEXT

Matches all 4 recorded answers

Recorded: 4 workbook cells. How we measure this · See the Rust code

Local names in 40 languages
LanguageName in Excel
ArabicFORMULATEXT
BulgarianFORMULATEXT
CzechFORMULATEXT
DanishFORMELTEKST
GermanFORMULATEXT
GreekFORMULATEXT
English (Australia)FORMULATEXT
English (United Kingdom)FORMULATEXT
English (United States)FORMULATEXT
SpanishFORMULATEXTO
EstonianFORMULATEXT
FinnishKAAVA.TEKSTI
FrenchFORMULETEXTE
HebrewFORMULATEXT
CroatianFORMULATEXT
HungarianKÉPLETSZÖVEG
IndonesianFORMULATEXT
ItalianFORMULATEXT
JapaneseFORMULATEXT
KoreanFORMULATEXT
LithuanianFORMULATEXT
LatvianFORMULATEXT
NorwegianFORMULATEXT
DutchFORMULETEKST
PolishFORMUŁA.TEKST
Portuguese (Brazil)FORMULATEXT
Portuguese (Portugal)FÓRMULA.TEXTO
RomanianFORMULATEXT
RussianФ.ТЕКСТ
SlovakFORMULATEXT
SlovenianFORMULATEXT
Serbian (Latin)FORMULATEXT
SwedishFORMELTEXT
ThaiFORMULATEXT
TurkishFORMÜLMETNİ
UkrainianFORMULATEXT
VietnameseFORMULATEXT
Chinese (Simplified)FORMULATEXT
Chinese (Hong Kong)FORMULATEXT
Chinese (Traditional)FORMULATEXT

Names from Microsoft's support site.

What it does

FORMULATEXT(reference)

FORMULATEXT(reference) returns the stored formula text of the referenced cell, including the leading equals sign. It inspects the workbook’s formula rather than converting the cell’s calculated value back into an expression.

Try it

Input cells (optional)

Example: {"B2": 3, "B3": 4}. A1 holds the formula. Other cells need values before a formula can read them.

Enter a formula, then calculate.

Runs locally in your browser with OneCalc. Its answer may differ from Excel. Use English function names and commas between arguments.

Input cells in this preview hold values rather than authored formulas, so FORMULATEXT cannot retrieve a stored formula here.

In Excel put =7*6 in B2, then enter =FORMULATEXT(B2) elsewhere. It returns the text "=7*6", while B2 displays 42. The preview input grid currently supplies cell values, so its B2=1 control returns a worksheet error instead of an authored formula.

Quirks

Microsoft documents #N/A when the target has no formula, the formula exceeds 8192 characters, worksheet protection hides it, or an external source workbook is closed. Invalid argument types give #VALUE!. A multi-cell reference selects its upper-left cell. A self-reference can return its own text without normal circular calculation.

How to implement

Resolve the reference to its first cell and ask the workbook host for its stored formula text. Do not evaluate that formula to obtain the text and do not reconstruct spelling from the result. The current host interface distinguishes “known cell without formula” (#N/A) from “formula information unavailable” (a typed refusal); it also rejects a closed external workbook as #N/A. The host must supply formula length/protection policy and formula-bar spelling. This is a host-backed function, not a pure numeric kernel.

Rust code

Show the CalcFunc source of this function

Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.

FORMULATEXT · 1 lines · calc-func/src/catalogue/host_facts.rs on GitHub
5 formulatext_fn "FORMULATEXT" (1, 1) [F "reference"] |s, a, sv| { formulatext(s, a, sv) }
formulatext · 12 lines · calc-func/src/catalogue/host_facts.rs on GitHub
fn formulatext(site: &Site<'_>, a: &[CalcValue], sv: &mut EvalServices<'_>) -> Step<CalcValue> {
    let at = first_cell(site, a, 0)?;
    // dc-ylr: Excel gives FORMULATEXT of a reference to a closed workbook #N/A.
    if sv.host().is_some_and(|host| host.is_external_sheet(at.sheet())) {
        return fail(WorksheetErrorCode::NA);
    }
    match sv.host().and_then(|host| host.formula_text(at)) {
        Some(Some(text)) => Ok(crate::catalogue::kit::text_value(&text)),
        Some(None) => fail(WorksheetErrorCode::NA),
        None => Err(site.not_modelled(Some(0))),
    }
}

Kernels shared with other functions

Argument and result plumbing

No implementation has been published with a Handbook test suite for this function.

Version differences

No same-input comparison between named Excel builds is recorded for this function here. The documented behaviour below is not a measurement of every Excel release.

Alternatives

ISFORMULA checks whether a cell contains a formula. TEXT formats its calculated value rather than returning its formula text.

Named variants

No named variants are recorded yet.

Suggest a correction or contribute an implementation · For agents