The VBA ATN function is listed under the math category of VBA functions. When you use it in a VBA code, it can return the arctangent of a number that you supplied. In simple words, arctangent is used to calculate the angles of a right triangle and ATN returns it for the number you specified.
- Number: The number for which you want to calculate the arctangent.
To practically understand how to use the VBA ATN function, you need to go through the below example where we have written a VBA code by using it:
Sub example_ATN() Range("B1").Value = Atn(Range("A1")) End Sub
In the above example, we have used the value from cell A1 where we have a number for which we want to calculate the arctangent, and then we have used the ATN to convert that value into an absolute number and enter that value in cell B1.
- If the value specified is a value other than a number or a number that can’t be recognized as a number, VBA will return the run-time 13 error.
- You can multiply the result returned by the ATN with pi/180 to convert it into radians and 180/pi to convert it into degrees.