Text functions

VALUETOTEXT

Matches all 6 recorded answers

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

Local names in 40 languages
LanguageName in Excel
ArabicVALUETOTEXT
BulgarianVALUETOTEXT
CzechVALUETOTEXT
DanishVÆRDITILTEKST
GermanVALUETOTEXT
GreekVALUETOTEXT
English (Australia)VALUETOTEXT
English (United Kingdom)VALUETOTEXT
English (United States)VALUETOTEXT
SpanishVALORATEXTO
EstonianVALUETOTEXT
FinnishARVO.TEKSTIKSI
FrenchVALEUR.EN.TEXTE
HebrewVALUETOTEXT
CroatianVALUETOTEXT
HungarianÉRTÉK.SZÖVEGGÉ
IndonesianVALUETOTEXT
ItalianVALUETOTEXT
JapaneseVALUETOTEXT
KoreanVALUETOTEXT
LithuanianVALUETOTEXT
LatvianVALUETOTEXT
NorwegianVALUETOTEXT
DutchVALUETOTEXT
PolishWARTOŚĆ.NA.TEKST
Portuguese (Brazil)VALUETOTEXT
Portuguese (Portugal)VALORPARATEXTO
RomanianVALUETOTEXT
RussianЗНАЧЕНИЕВТЕКСТ
SlovakVALUETOTEXT
SlovenianVALUETOTEXT
Serbian (Latin)VALUETOTEXT
SwedishVÄRDETILLTEXT
ThaiVALUETOTEXT
TurkishDEĞERMETİN
UkrainianVALUETOTEXT
VietnameseVALUETOTEXT
Chinese (Simplified)VALUETOTEXT
Chinese (Hong Kong)VALUETOTEXT
Chinese (Traditional)VALUETOTEXT

Names from Microsoft's support site.

What it does

VALUETOTEXT(value, [format])

VALUETOTEXT renders a value as text. Its reason to exist is that Excel has two different, equally legitimate answers to "what does this value look like as text", and this function lets you ask for either one.

Concise (format = 0, the default) returns the value as it would be rendered in a cell with General formatting. This is the display register: it is what a human reading the sheet sees. Microsoft's page states this equivalence explicitly, and it is the useful anchor — the output is defined by reference to General-format rendering, not by an independent formatting rule.

Strict (format = 1) returns the value in a form suitable for embedding in a formula. Microsoft's page describes it as including escape characters and row delimiters, and generating a string that can be parsed when entered into the formula bar. Text is quoted, with inner quotes escaped; Booleans, numbers and errors are left unquoted. This is the round-trip register: the point is that pasting the result into the formula bar reconstructs the value.

The distinction is exactly the distinction between showing a value and denoting it. "Hello" displays as Hello and denotes as "Hello". The empty string displays as nothing and denotes as "" — and only the second of those two is recoverable.

For anyone building tooling on top of a workbook, that makes strict mode the interesting one: it is the only ordinary worksheet function that produces a machine-reparseable rendering of an arbitrary value.

Arguments

VALUETOTEXT(value, [format])

ArgumentRequiredMeaning (as documented by Microsoft)
valueyesThe value to return as text.
formatno0 (default) concise; 1 strict. Anything else is documented as #VALUE!.

The format argument is a mode selector with exactly two admitted values, and this is one of the few places in the text family where an out-of-range option is documented as an error rather than being clamped or ignored. Do not pass TRUE expecting it to mean 1 without checking; whether the logical coerces into the admitted set is not something this page asserts.

The first position takes any value, which is the function's whole point. It is not restricted to scalars in the sense of rejecting other kinds — it is the scalar renderer, and how it responds to an array argument is discussed below.

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.

Quirks

Result and edge cases

The return kind is Text. Upstream's contract records the result as always a scalar text value.

  • Errors are rendered, not propagated, in one specific sense — and propagated in another. Microsoft's strict-mode description says errors are left unquoted, which implies they are rendered as their error text. Upstream's contract, by contrast, records error values in the first argument as propagating in both format modes. These two readings can both be true of different situations — an error inside an array being rendered, versus an error arriving as the whole scalar argument — but the Handbook has not established which applies where. This is a genuine open point and it is listed below rather than resolved by assertion.
  • Numbers render as decimal strings in concise mode, which means the General-format rendering, including its width-dependent behaviour in a cell. Whether VALUETOTEXT's rendering depends on column width the way a cell's does is not established and is a probe worth running.
  • The empty string is distinguishable in strict mode ("") and not in concise mode.
  • An empty referenced cell delivers Empty, distinct from an omitted argument; see the value universe.
  • Array arguments. ARRAYTOTEXT is the function for arrays. Whether VALUETOTEXT lifts elementwise over an array or delegates to array rendering is a shape question the Handbook has not settled; see the probes below.

Errors

The tension between error propagation and error rendering noted above is unresolved; treat the second row as upstream's reading rather than as settled Handbook fact.

How to implement

Notes for implementers

  • Do not write your own number renderer. Concise mode is defined as General-format rendering, so it inherits every subtlety of that: the switch to scientific notation, the significant-digit budget, negative-zero handling. Reusing the engine's General formatter is the only way to stay consistent; a fresh format!("{}", x) will diverge.
  • Strict mode is a grammar, so write it as one. Quoting, quote-escaping (doubling), the column separator, and the row separator are all part of a syntax that must reparse. The separator characters are locale-dependent in Excel's formula language, which means strict mode has a locale dependency that concise mode does not obviously share.
  • The two modes must agree on nothing. Do not implement strict as concise-plus-quotes; the number renderings can legitimately differ.
  • Decide the error question explicitly and test it: error as argument, error inside an array, and error as the format argument are three different paths.
  • Validate format before rendering, so that VALUETOTEXT(error_value, 7) has a defined precedence between the two failures.

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.

VALUETOTEXT · 1 lines · calc-func/src/catalogue/text_format.rs on GitHub
6 valuetotext_fn "VALUETOTEXT" (1, 2) [V "value", V "format"] |s, a, sv| { valuetotext(s, a) }
valuetotext · 5 lines · calc-func/src/catalogue/text_format.rs on GitHub
fn valuetotext(site: &Site<'_>, a: &[CalcValue]) -> Step<CalcValue> {
    let strict = binary_flag(site, a, 1)?;
    let shown = value_text(site, 0, &a[0], strict)?;
    Ok(crate::catalogue::kit::text_value(&shown))
}

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 comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.

Alternatives

Relationships

  • ARRAYTOTEXT — the array counterpart, introduced alongside this function and sharing its format argument and its two registers. The pair splits by input shape: one value, or a grid.
  • TEXT — the formatting function, and the one readers confuse with this. TEXT(x, fmt) applies a number-format string you supply; VALUETOTEXT applies General formatting or a fixed strict grammar. TEXT cannot render a logical or an error usefully; VALUETOTEXT is defined for every value kind.
  • VALUE — despite the name, not the inverse. VALUE parses text into a number under locale rules; VALUETOTEXT renders any value as text. The nearest thing to an inverse of strict mode is the formula parser itself.
  • T — the old narrow relative: returns the text if the argument is text and the empty string otherwise. It is a filter, not a renderer.
  • CONCAT and & perform implicit to-text conversion by the general rule in coercion and lifting. That conversion is not guaranteed to agree with VALUETOTEXT(x, 0) for every kind, and where they differ is worth knowing.

Named variants

No named variants are recorded yet.

Suggest a correction or contribute an implementation · For agents