This Excel tutorial explains how to use the Excel FORMAT function (as it applies to numeric values) with syntax and examples.
format is optional. It is the format to apply to the expression. You can either define your own format or use one of the named formats that Excel has predefined such as:
Let's look at some Excel FORMAT function examples and explore how to use the FORMAT function in Excel VBA code:
Description
The Microsoft Excel FORMAT function takes a numeric expression and returns it as a formatted string.Syntax
The syntax for the Microsoft Excel FORMAT function is:Format ( expression, [ format ] )
Parameters or Arguments
expression is the value to format.format is optional. It is the format to apply to the expression. You can either define your own format or use one of the named formats that Excel has predefined such as:
Format | Explanation |
---|---|
General Number | Displays a number without thousand separators. |
Currency | Displays thousand separators as well as two decimal places. |
Fixed | Displays at least one digit to the left of the decimal place and two digits to the right of the decimal place. |
Standard | Displays the thousand separators, at least one digit to the left of the decimal place, and two digits to the right of the decimal place. |
Percent | Displays a percent value - that is, a number multiplied by 100 with a percent sign. Displays two digits to the right of the decimal place. |
Scientific | Scientific notation. |
Yes/No | Displays No if the number is 0. Displays Yes if the number is not 0. |
True/False | Displays True if the number is 0. Displays False if the number is not 0. |
On/Off | Displays Off if the number is 0. Displays On is the number is not 0. |
Applies To
The FORMAT function can be used in the following versions of Microsoft Excel:- Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000
Type of Excel Function
The FORMAT function can be used in Microsoft Excel as the following type of function:- VBA function (VBA)
Example (as VBA Function)
The FORMAT function can only be used in VBA code in Microsoft Excel.Let's look at some Excel FORMAT function examples and explore how to use the FORMAT function in Excel VBA code:
Format(210.6, "#,##0.00") Result: '210.60' Format(210.6, "Standard") Result: '210.60' Format(0.981, "Percent") Result: '98.10%' Format(1267.5, "Currency") Result: '$1,267.50'For example:
Dim LValue As String LValue = Format(0.981, "Percent")