The VBA Exp Function

Related Function:
VBA Log

Description

The VBA Exp function returns the value of the exponential function ex at a supplied value of x.

I.e. the function returns the mathematical constant e (the base of the natural logarithm) raised to a supplied power.

The syntax of the Exp function is:

Exp( Number )

Where the supplied Number is the power that you want to raise the constant e to.

VBA Exp Function Examples

The following VBA code shows three examples of the VBA Exp function.

 ' Calculate ex for three values of x.Dim val1 As DoubleDim val2 As DoubleDim val3 As Doubleval1 = Exp( -0.1 )' The variable val1 is now equal to 0.90483741803596.val2 = Exp( 0 )' The variable val2 is now equal to 1.0.val3 = Exp( 1.5 )' The variable val3 is now equal to 4.48168907033806.

In the above VBA code:

• For the value -0.1, the Exp function calculates ex to be 0.90483741803596;
• For the value 0, the Exp function calculates ex to be 1.0;
• For the value 1.5, the Exp function calculates ex to be 4.48168907033806.

VBA Exp Function Errors

If the Number that is supplied to the Exp function is greater than 709.782712893, you will get the error:

Run-time error '6': Overflow If the Exp function is supplied with a value that cannot be interpreted as a number, it will return the error:

Run-time error '13': Type mismatch 