Last Updated on January 11, 2023 by token
1. CDbl VBA Function – Description
The CDbl VBA function returns a value with the Double data type . It is a number between -1.79769313486232e +308 to -4.94065645841247E-324 . The Double data type is 8 bytes in memory. We usually use functions when converting very large floating point numbers. Using the function for numbers outside the range or for non-numeric data will return an error. This function can be used to convert a floating point number written with a comma, not a period, to a floating point number recognized by VBA. The function converts text to a number.
2. VBA CDbl Function – Syntax
CDbl (Expression) As Double
Expression : Any number from -1.79769313486232e + 308 to -4.94065645841247E-324 stored in any data type (including String).
Function return : Double / A floating point number ranging from -1.79769313486232e + 308 to -4.94065645841247E-324.
3. VBA CDbl function – Example
How to use CDbl function in VBA Excel? Below are examples of using the CDbl function in the VisualBasic Editor.
Example 1: Conversion to type Double. CDbl – function example. The result in the MsgBox window.
Dim strValue As String strValue = "1234233,12343" MsgBox CDbl (strValue)
Example 2: CDbl – function example. Convert to Double. The result in a sheet cell.
Dim strValue As String strValue = "1234233,12343" Range ("A1") = CDbl (strValue) * 5
4. VB CDbl function – Additional information
- The function used for numbers outside the range -1.79769313486232e + 308 to -4.94065645841247E-324 will return an error.
- This function can be used to convert a floating point number written with a comma, not a period, to a floating point number recognized by VBA.
5. CDbl VisualBasic function – Where to use?
The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Excel 365.
The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address: VBA functions .