Share via


WorksheetFunction.USDollar Method

Converts a number to text format and applies a currency symbol. The name of the method (and the symbol that it applies) depends upon the language settings.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function USDollar ( _
    Arg1 As Double, _
    Arg2 As Double _
) As String
'Usage
Dim instance As WorksheetFunction
Dim Arg1 As Double
Dim Arg2 As Double
Dim returnValue As String

returnValue = instance.USDollar(Arg1, _
    Arg2)
string USDollar(
    double Arg1,
    double Arg2
)

Parameters

  • Arg1
    Type: System.Double

    A reference to a cell containing a number, or a formula that evaluates to a number.

  • Arg2
    Type: System.Double

    The number of digits to the right of the decimal point. If Arg2 is negative, the number is rounded to the left of the decimal point. If you omit decimals, it is assumed to be 2.

Return Value

Type: System.String

Remarks

The USDollar method converts a number to text using currency format, with the decimals rounded to the specified place. The format used is $#,##0.00_);($#,##0.00).

The major difference between formatting a cell that contains a number with the Format Cells command and formatting a number directly with the Dollar(Double, Object) method is that Dollar(Double, Object) converts its result to text. A number formatted with the Format Cells command is still a number. You can continue to use numbers formatted with Dollar(Double, Object) in formulas, because Excel converts numbers entered as text values to numbers when it calculates.

See Also

Reference

WorksheetFunction Interface

WorksheetFunction Members

Microsoft.Office.Interop.Excel Namespace