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 Double
Dim val2 As Double
Dim val3 As Double
val1 = 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:


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

VBA Run Time Error 6 Message Box


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

VBA Run Time Error 13 Message Box