Skip to content

Lesson 76 of 92 · Free Excel Course

Excel · Excel function reference

Excel FORMAT Function? Use the TEXT Function Instead (Codes and Examples)

Excel has no FORMAT worksheet function (=FORMAT gives #NAME?). Use TEXT with format codes for currency, dates, percent, leading zeros and phone numbers.

If you are looking for the Excel FORMAT function, here is the short answer: Excel has no FORMAT worksheet function. FORMAT is a VBA function, used inside macros, and versions of it also exist in Microsoft Access and in DAX (Power BI and Power Pivot). Type =FORMAT(A2,"0.00") in a cell and Excel returns #NAME?, its error for a function name it doesn't know. In a worksheet, the function that does the job is TEXT. It takes a number or date and returns it as text in the format you choose: =TEXT(1234.567,"$#,##0.00") returns $1,234.57. TEXT is in Excel for Microsoft 365 (Windows, Mac and the web), Excel 2024, Excel 2021, Excel 2019 and Excel 2016. If you only want a cell to look different, you don't need a formula at all: a custom number format does it and keeps the value a number.

Syntax

=TEXT(value, format_text)
  • value (required): the number, date or time to format. It can be typed in, a cell reference or a calculation.
  • format_text (required): the format code, in double quotation marks, such as "0.0%" or "mm/dd/yyyy". There is no default. Leave out the quotes and Excel returns an error.

The codes are the same ones you see under Custom in the Format Cells dialog. The most useful:

You wantCodeExample result
Currency$#,##0.00$1,234.57
Thousands separator, no decimals#,##012,200,000
Percent0.0%28.5%
Leading zeros (5 digits)0000000042
Datemm/dd/yyyy or mmm d, yyyy11/22/2026, Nov 22, 2026
Day or month namedddd or mmmmSunday, November
Timeh:mm AM/PM1:29 PM
US phone[<=9999999]###-####;(###) ###-####(123) 456-7898

0 always shows a digit (adding zeros if needed); # shows a digit only if there is one. Codes aren't case-sensitive, and an m straight after h means minutes, not month.

The real FORMAT function, in VBA

If you are writing a macro, VBA's Format takes an expression and an optional format, and returns a string:

MsgBox Format(1234.567, "$#,##0.00")                            ' shows "$1,234.57"
MsgBox Format(Date, "dddd, mmm d yyyy")                         ' e.g. "Sunday, Nov 22 2026"

It only works inside the Visual Basic Editor, never in a cell. Start with Macros and VBA.

Examples

Microsoft's examples

These come from Microsoft's TEXT function page, with the value typed straight into each formula.

B2=TEXT(1234.567,"$#,##0.00")
AB
1FormulaResult
2=TEXT(1234.567,"$#,##0.00")$1,234.57
3=TEXT(0.285,"0.0%")28.5%
4=TEXT(1234,"0000000")0001234
5=TEXT(12200000,"0.00E+00")1.22E+07
6=TEXT(1234567898,"[<=9999999]###-####;(###) ###-####")(123) 456-7898
Currency rounds to two decimals; 0000000 pads 1234 to seven digits; the phone code puts the area code in brackets for numbers over seven digits.

One date, five looks

TEXT is how you pull a day name, a month name or an ISO date out of a real date. Here A2 holds 11/22/2026.

C2=TEXT(A2,"dddd")
ABC
1DateFormulaResult
211/22/2026=TEXT(A2,"dddd")Sunday
3=TEXT(A2,"mmmm")November
4=TEXT(A2,"mmm d, yyyy")Nov 22, 2026
5=TEXT(A2,"mm/dd/yyyy")11/22/2026
6=TEXT(A2,"yyyy-mm-dd")2026-11-22
The date itself never changes; each TEXT formula returns a different text version of it.

yyyy-mm-dd is handy for file names and for exports to other systems, because it sorts correctly even as text.

Leading zeros and a sentence

Employee IDs, ZIP codes and part numbers often need a fixed number of digits. And whenever you join a number into a sentence with &, Excel drops the cell's formatting, so you need TEXT to bring it back.

C4="Store 3 grew "&TEXT(A4,"0.0%")
ABC
1ValueFormulaResult
242=TEXT(A2,"00000")00042
32134=TEXT(A3,"00000")02134
40.124="Store 3 grew "&TEXT(A4,"0.0%")Store 3 grew 12.4%
50.124="Store 3 grew "&A5Store 3 grew 0.124
Without TEXT (row 5) the sentence shows the raw decimal. 2134 becomes the ZIP code 02134.

TEXT versus a custom number format

TEXT's result is text, not a number. It looks right, but SUM skips it. A custom number format changes only how the cell looks.

B5=SUM(B2:B4)
AB
1Number (custom format)TEXT copy
2$1,234.57$1,234.57
3$28.50$28.50
4$42.00$42.00
5$1,305.07$0.00
Column A holds 1234.567, 28.5 and 42 with the custom format $#,##0.00 and adds up to $1,305.07 (1305.067). Column B is =TEXT(A2,"$#,##0.00") copied down; its SUM is 0, shown here in the same format.

To apply a custom format instead of using TEXT:

  1. Select the cells and press Ctrl+1 (on a Mac, Command+1).
  2. On the Number tab, choose Custom.
  3. In the Type box, enter a code from the table above, such as $#,##0.00, and click OK.

Microsoft notes that Excel for the web can't create new custom formats: choose Open in Excel to do it in the desktop app. More options are in Format cells.

Common errors

  • #NAME? on =FORMAT(...): there is no FORMAT worksheet function. Replace it with TEXT; the format code usually works as it is.
  • An error because the code has no quotes: =TEXT(A2,mm/dd/yyyy) fails. Write =TEXT(A2,"mm/dd/yyyy").
  • Totals of 0 or numbers that won't sort properly: TEXT returned text. Keep the original numbers in their own column and use TEXT only for display, or use a custom number format. To turn text back into a number, multiply by 1 (=D2*1) or see the VALUE function.
  • Months where you wanted minutes (or the reverse): m and mm on their own mean month. Put them next to an hour or seconds code, as in "h:mm" or "mm:ss", and they mean minutes.
  • Colors are ignored: a code like [Red]0.00 colors a cell in Format Cells, but TEXT can't return color.
  • Codes that work on one PC and not another: separators and some codes depend on regional settings and Excel's language. Check the format on the computer that will use the file.

Related functions

  • Text functions: the lesson on joining, splitting and cleaning text, including TEXT in sentences.
  • VALUE function: turns text that looks like a number back into a number.
  • LEN function: check that a padded ID really has five characters.
  • Dates and times: how Excel stores the dates you format.

Try it yourself

Download the practice workbook. The Practice sheet has six yellow cells: currency, percent, leading zeros, a day name, a phone number and a sentence. Write a TEXT formula in each and check it against the Answers sheet, which also shows SUM returning 0 on TEXT results.

Frequently asked questions

Is there a FORMAT function in Excel?

Not in a worksheet cell. FORMAT is a VBA function (used in macros) and also exists in Access and in DAX for Power BI. Typing =FORMAT in a cell returns #NAME?. The worksheet function that does the same job is TEXT, for example =TEXT(A2,"$#,##0.00").

What is the difference between TEXT and Format Cells?

Format Cells (Ctrl+1) changes how a number looks but keeps it a number, so it still adds up. TEXT returns a new value that is text, which is what you need when you join a number into a sentence but not when you want to keep calculating with it.

How do I keep leading zeros in Excel?

For a value you'll display or export, use =TEXT(A2,"00000"): the number of zeros is the total number of digits, so 42 becomes 00042. To keep the zeros while still storing a number, apply the custom number format 00000 with Ctrl+1 instead.

Why does my TEXT date format show the wrong month or minutes?

In format codes, m means month unless it follows h (hours) or comes before s (seconds), where it means minutes. Write "h:mm" for times and "mm/dd/yyyy" for dates. Format codes also depend on your Excel language and regional settings.