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 from here.
- Number: The Number is the power that you want to raise the constant e to.
To practically understand how to use VBA EXP function, you need to go through the below example where we have written a vba code by using it:
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 the cell A1 and it has returned the value of the exponential function ex 4.05519996684467 in cell B1.
- 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.