What is VBA EXP Function
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.
how to use it
To use VBA's EXP function you need to understand its syntax and arguments:
- Number: The Number is the power that you want to raise the constant e to.
Example to use EXP Function in VBA
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.
Below are some important points which you need to take care while using EXP function in VBA.
- 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.
About the Author
Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can ﬁnd him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.