Excel VBA Exp Function

VBA Exp Function: The Exp function in VBA returns the value of the exponential function ex (mathematical constant ‘e’ raised to specified power) for the given value of x.

Syntax

Exp (Number)

Parameter

Number (required) –This parameter represents the power that you want to raise the constant e to.

Return

This function returns the value of the exponential function ex (mathematical constant ‘e’, the base of the natural logarithm raised to specified power) for the given value of x.

Example 1

Sub ExpFunction_Example1()
 ' Calculating the ex for three values of x.
 Dim Exp_val As Double
 Exp_val = Exp(2)
 ' The variable Exp_val will return value equal to 7.38905609893065
 Cells(1, 1).Value = Exp_val
 End Sub 

Output

7.38905609893065

VBA Exp Function

Example 2

Sub ExpFunction_Example2()
 ' Calculating the ex for three values of x.
 Dim Exp_val As Double
 Exp_val = Exp(1.5)
 ' The variable Exp_val is now equal to 4.48168907033806
 Cells(1, 1).Value = Exp_val
 End Sub 

Output

4.48168907033806

VBA Exp Function

Example 3

Sub ExpFunction_Example3()
 ' Calculating the ex for three values of x.
 Dim Exp_val As Double
 'passing number greater than 709.782712893,
 Exp_val = Exp(800)
 ' The variable Exp_val will return overflow run-time error
 Cells(1, 1).Value = Exp_val
 End Sub 

Output

Excel VBA Exp Function