VBA Atn function in Excel is categorizes as Math(Mathematical) & Trig function. This is a built-in Excel and VBA Function. This function returns the arctangent of a number in radians, not degrees. Atn function is an inverse trigonometric function of the TAN function. VBA Atn function takes the ratio of two sides of a right triangle and returns the corresponding angle in radians.
- Convert degrees to radians, multiply degrees with pi/180.
- To convert radians to degrees, multiply radians with 180/pi.
We can use this function in VBA and can’t use in Excel. This function use in either procedure or function in a VBA editor window in Excel. This VBA Atn Function in any number of times in any number of procedures or functions. Let us learn what is the syntax and parameters of the Atn function, where we can use this Atn Function and real-time examples in Excel VBA.
- Overview
- Syntax of VBA Atn Function
- Parameters or Arguments
- Where we can apply or use VBA Atn Function?
- Example 1: Find the Arctangent value(-2) of a number
- Example 2: Find the Arctangent value(2) of a number
- Example 3: Find the Arctangent value(8.8) of a number
- Instructions to Run VBA Macro Code
- Other Useful Resources
Syntax of VBA Atn Function
The syntax of the Atn Function in VBA is
Atn(Number)
The Atn function returns value is a Double data type.
Parameters or Arguments:
The Atn function has one argument in Excel VBA.
where
Number:The Number is a required parameter. It represents a numeric value which we want the arctangent of number.
Where we can apply or use VBA Atn Function?
We can use this Atn Function in VBA MS Office 365, MS Excel 2016, MS Excel 2013, 2011, Excel 2010, Excel 2007, Excel 2003, Excel 2016 for Mac, Excel 2011 for Mac, Excel Online, Excel for iPhone, Excel for iPad, Excel for Android tablets and Excel for Android Mobiles.
Example 1: Find the Arctangent value(-2) of a number
Here is a simple example of the VBA Abs function. This below example finds the arctangent value(-2) of a number.
'Find the arctangent value(-2) of a number Sub VBA_Atn_Function_Ex1() 'Variable declaration Dim iValue As Integer Dim dResult As Double iValue = -2 dResult = Atn(iValue) MsgBox "The Arctangent value(-2)of a number : " & vbCrLf & vbCrLf & dResult & " radians", vbInformation, "VBA Atn Function" End Sub
Output: Here is the screen shot of the first example output.
Example 2: Find the Arctangent value(2) of a number
Here is a simple example of the VBA Abs function. This below example finds the arctangent value(2) of a number.
'Find the arctangent value(2) of a number Sub VBA_Atn_Function_Ex2() 'Variable declaration Dim iValue As Integer Dim dResult As Double iValue = 2 dResult = Atn(iValue) MsgBox "The Arctangent value(2)of a number : " & vbCrLf & vbCrLf & dResult & " radians", vbInformation, "VBA Atn Function" End Sub
Output: Here is the screen shot of the second example output.
Example 3: Find the Arctangent value(8.8) of a number
Here is a simple example of the VBA Abs function. This below example finds the arctangent value(8.8) of a number.
'Find the arctangent value(8.8) of a number Sub VBA_Atn_Function_Ex3() 'Variable declaration Dim iValue As Integer Dim dResult As Double iValue = 8.8 dResult = Atn(iValue) MsgBox "The Arctangent value(8.8)of a number : " & vbCrLf & vbCrLf & dResult & " radians", vbInformation, "VBA Atn Function" End Sub
Output: Here is the screen shot of the third example output.
Instructions to Run VBA Macro Code or Procedure:
You can refer the following link for the step by step instructions.
Instructions to run VBA Macro Code
Other Useful Resources:
Click on the following links of the useful resources. These helps to learn and gain more knowledge.
VBA Tutorial VBA Functions List VBA Arrays in Excel Blog
VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers