VBA EXP Function (Syntax + Example)

Last Updated: February 23, 2024
puneet-gogia-excel-champs

- Written by Puneet

The VBA EXP function is listed under the math category of VBA functions. When you use it in a VBA code, it returns the value of the exponential function ex at a supplied value of x. In simple words, it calculates the mathematical constant e (the base of the natural logarithm) raised to a supplied power. Learn more about it here.

Related – Constants in VBA

Syntax

Exp(Number)

Arguments

  • Number: The Number is the power that you want to raise the constant e to.

Example

To practically understand how to use the VBA EXP function, you need to go through the below example where we have written a vba code by using it:

example-vba-exp-function
Sub example_EXP()
Range("B1").Value = Exp(Range("A1"))    
End Sub

In the above example, we have used EXP and the supplied value of x from cell A1 and it has returned the value of the exponential function ex 4.05519996684467 in cell B1.

Notes

  • If the value specified is a value other than a number or a string that can’t be recognized as a number, VBA will return the run-time 13 error.
  • And if that value is greater than 709.782712893 then VBA will return the run-time 6 error.