Return to VBA Code Examples

VBA CDbl Function – Convert to Double

This tutorial will demonstrate how to use the CDbl VBA function to convert expressions to double data type.

CDbl Function

VBA CDbl Convert Expression to Integer

The VBA CDbl function can be used to convert expressions to double data type inside VBA code.

VBA CDbl Converting String to Double

The VBA CDbl function can be used to convert strings to doubles if the characters in the string have a meaning as numbers.

VBA CDbl Run-Time Error 13 Type Mismatch

Using VBA CDbl function with strings that contain non-numerical characters or characters that don’t have meaning in numerical context will result in a Run-Time error ’13’: Type mismatch.

VBA CDbl Regional Settings

VBA CDbl function has different behavior converting strings with comma or dot.  It uses the Regional Settings of the operating system for decimal separator and digit separator.

VBA CDbl Converting Booleans to Doubles

VBA CDbl function can convert boolean variables to doubles. If the evaluated expression is true the resulting double is -1 and if the evaluated expression is false the resulting double is 0.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! automacro

Learn More!!

VBA CDbl Converting Dates to Doubles

VBA CDbl function can convert a date variable to an integer. The returned value is the internal number used by excel for date storage rounded.