The VBA SIN function is listed under the math category of VBA functions. When you use it in a VBA code, it returns the sine of a supplied angle. You can learn more about sine here.
Syntax
Sin(Number)
Arguments
- Number: An integer to specify the angle (in radians) that you want to calculate the sine of.
Example
To practically understand how to use the VBA SIN function, you need to go through the below example where we have written a vba code by using it:
Sub example_SIN()
Range("B1").Value = Sin(Range("A1"))
End Sub
In the above code, we have used SIN to get the sine of the angle which we have in the cell in A1 and returned the result in cell B1.
Notes
- 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 SIN with pi/180 to convert it into a radian and 180/pi to convert it into degrees.
More Tutorials
⇠ Back to VBA Function List | What is VBA in Excel
Helpful Links – Developer Tab – Visual Basic Editor – Run a Macro – Personal Macro Workbook – Excel Macro Recorder – VBA Interview Questions – VBA Codes