Learn Excel - Simplify Life with Excel Concepts

Excel CDbl Function (VBA)

CDbl Function VBA Code

How to use the CDbl Function (VBA)

This Excel tutorial explains how to use the Excel CDbl function with syntax and examples using VBA.

SUMMARY:

The Excel VBA CDbl function converts an expression into a Double data type.

For example,

  • The VBA Code CDbl("2.00000001") would return 2.00000001
  • The VBA Code CDbl(2.00001 *2.00001) would return 4.0000400001

PURPOSE:

To converts a value to double data type or double precision floating point numbers.

RETURN VALUE:

The CDbl function returns a Double value.

SYNTAX:

CDbl( expression )

ARGUMENTS:

The CDbl function syntax has the following arguments:

  • expression: Required. The expression is that you want to convert to a Double data type.
    • The "expression" can be any number between (-4.94 E-324) and (1.79 E308).
    • If "expression" is outside this range, then an error occurs.

REMARKS:

  • The CDbl function can only be used in VBA code in Microsoft Excel.
  • The Double data type is a Value data type.
  • This function uses the locale setting to identify the different decimal separators and thousand separators.
  • The CDbl function is used to convert an expression to a Double.

Useful Links: Link 1Link 2Link 3Link 4