Solving #VALUE! Errors in Custom Format String Formulas
You wrote a one-line label generator: =TEXT(A2, "MMM YYYY - $#,##0.00") to produce strings like “Mar 2026 – $1,234.56” from a date and amount. It worked on every test cell — until the production data came through and dozens of rows return #VALUE!. The data looks identical to the test set. Same date format. Same number range. Yet TEXT refuses to apply the format. Custom format strings in Excel have over fifty special characters, and three of them — @, *, and _ — silently break the formula when they appear in the input data or are accidentally typed into the format code.
Before You Start: The 60-Second Diagnostic
Three checks:
- Test the inputs separately:
=TEXT(A2, "MMM YYYY")and=TEXT(B2, "$#,##0.00")independently. If both work alone, the issue is in how you combine them. - Verify the input data type:
=ISNUMBER(A2)should be TRUE for both dates and amounts (dates are numbers). - Check for invalid format characters: A bare
@in the format string forces text-handling mode; you may not want that.
Step-by-Step Solution
H2: Master the Most Common Format Tokens
The placeholder language for TEXT():
For numbers:
– 0 — digit placeholder, prints 0 if no digit
– # — digit placeholder, prints nothing if no digit
– , — thousands separator
– . — decimal point
– % — percent (multiplies by 100)
– $ — literal dollar sign
For dates:
– M — month digit (no leading zero)
– MM — month digit (with leading zero)
– MMM — abbreviated month name (Jan, Feb)
– MMMM — full month name (January)
– D, DD, DDD, DDDD — day equivalents
– YY, YYYY — 2-digit and 4-digit year
Common mistakes:
– mm:ss — treats mm as minutes (since it follows :)
– MM in non-date contexts — treated as text
– m alone is ambiguous and may produce unexpected results
H2: Fix Conflicting Single-Letter Tokens
The biggest gotcha: m is both “minute” and “month” depending on context. After h or in a time-only format, it means minutes. Otherwise, it means months.
Wrong:
=TEXT(A2, "h:m") (means h:minutes — fine)
=TEXT(A2, "m") (means month — but if A2 is a time, gets month of serial date)
Right (explicit):
=TEXT(A2, "h:mm") — minutes with leading zero
=TEXT(A2, "MMM") — abbreviated month name
=TEXT(A2, "[mm]") — total minutes
Bracketed [mm] forces minute interpretation regardless of context.
H2: Combine Date and Number in One Format
Mixed-type format strings work, but each segment must be valid for its data:
=TEXT(A2, "MMM YYYY") & " - " & TEXT(B2, "$#,##0.00")
This concatenates two TEXT calls. Trying to combine date and number tokens in a *single* TEXT call:
=TEXT(A2, "MMM YYYY - $#,##0.00")
…will not work as expected because A2 is one value and the format expects to apply both date and number formatting to it.
H2: Handle Locale-Specific Format Codes
Excel format codes vary by Office display language:
- US English:
MMMfor month,DDfor day. - French:
mmmfor month,jjfor day (j = jour). - German:
MMMfor month,TTfor day (T = Tag).
If your workbook was created in one locale and opened in another, format codes are auto-translated. But formulas built via copy-paste from web tutorials may use the original locale’s codes, producing #VALUE! after a locale change. Use only English codes in your formulas; Excel’s internal engine accepts them in any locale.
H2: Use Sample-Driven Format Codes
When unsure about the syntax for a specific output:
- Select an empty cell.
- Right-click → Format Cells (Ctrl + 1).
- Number tab → choose Custom.
- Manually type or pick a format until the preview shows what you want.
- Copy the format code from the Type box.
- Paste it into your TEXT formula.
This guarantees the format code is syntactically correct.
Information Gain Box: The Hidden Section Separator
Here is the format code feature documented in only a few corners of Microsoft’s reference: custom format codes accept up to four sections, separated by semicolons: positive number ; negative number ; zero ; text. Most users only fill in the first section; understanding all four unlocks surgical formatting.
Example:
$#,##0.00;[Red]($#,##0.00);"--";@
- Positive:
$1,234.56 - Negative:
($1,234.56)in red - Zero:
-- - Text: passes through unchanged
When a TEXT() formula returns #VALUE! for some rows and works for others, the cause is often a value that does not match the expected section. For example, a format that only specifies positive cases will fail on negatives. Always include all four sections in production-grade format codes — even if some sections are just "-" or empty strings. This robustness eliminates an entire class of intermittent format failures.
Comparison Table: Wrong Way vs. Correct Way
| Goal | Wrong Way (#VALUE!) | Correct Way |
|---|---|---|
| Month + year + amount | =TEXT(A2, "MMM YYYY $#,##0") (one TEXT, two types) |
=TEXT(A2, "MMM YYYY") & " " & TEXT(B2, "$#,##0") |
| Total minutes | =TEXT(A2, "mm") (ambiguous) |
=TEXT(A2, "[mm]") (forced minute interpretation) |
| Negative numbers | Single section format | Four-section format: pos;neg;zero;text |
| Cross-locale formula | Locale-specific codes (jj, TT) | English codes (DD, MM, YYYY) work everywhere |
| Padded zeros | =TEXT(123, "##") |
=TEXT(123, "000") |
| Custom strings | Mixed quotation | Wrap literals in quotes: "Order #"##### |
| Verifying format | Trial and error in formula | Use Format Cells dialog to preview |
Original Image Descriptions
Screenshot 1: Show a TEXT formula =TEXT(A2, "MMM YYYY - $#,##0.00") returning #VALUE!. Below, show diagnostic cells with =TEXT(A2, "MMM YYYY") returning “Mar 2026” and =TEXT(B2, "$#,##0.00") returning “$1,234.56”. Draw a red circle around the combined format code and a red arrow to the working separated versions. Add a red annotation: “One TEXT call cannot handle date + number formats together.”
Screenshot 2: Show the Format Cells → Custom dialog with the four-section format $#,##0.00;Red;"--";@ and the Sample preview showing each case. Draw a red circle around the four sections separated by semicolons. Add a red annotation: “Four sections = robust formatting for positive, negative, zero, and text.”
Frequently Asked Questions
Q: Why does TEXT return #VALUE! only on certain rows?
A: Almost always because those rows contain a value type the format code does not handle. Example: a format like "0.00" works for numbers but fails for text. A format like "MMM YYYY" works for dates but fails for plain numbers. Diagnose by checking the type of failing rows: =ISNUMBER(A2), =ISTEXT(A2), =ISDATE(A2) (no native function, use =NOT(ISTEXT(A2))*ISNUMBER(A2) for likely-date check).
Q: Can I include emoji or special characters in a TEXT format code?
A: Yes — any character not reserved by the format syntax is treated as a literal. Wrap special characters in quotes to be safe: "📈 " followed by the format code. Reserved characters that need quoting: 0 # ? . , % * _ $ + ( ) / - @ [ ]. Unicode characters generally pass through unmodified.
Q: My TEXT formula works in Excel desktop but fails in Excel Online. Why?
A: Excel Online has historically had limited support for some advanced format codes, particularly conditional formatting within format strings (the [Red] and [Blue] markers). Most basic format codes work identically across platforms; advanced features like custom color tags and locale-conditional formatting may produce different output. Test format-heavy formulas in target environments.