# How to Use the Excel VBA Sin Function (2 Examples)

Similar to the general Excel **SIN **function, Excel VBA also has a dedicated function to get the Sine values for radian angles. So, you can directly apply the Sin function while writing a program with VBA. This article demonstrates how to get sine values for radians and degree angles with the Excel **VBA ****Sin **function.

**Purpose of the VBA Sin Function**

When given an angle, the **Sin **function calculates the ratio of the height divided by its hypotenuse for a right-angled triangle. The value range for the Sin function is -1 to 1.

**Syntax of the VBA Sin Function**

Sin(Number As Double)

**Arguments of the VBA Sin Function**

Argument | Explanation |

Number As Double | The radian angle value for which the Sine value is calculated |

**Example #1: Get Value for Sin Angle with Radian**

Consider the following sample data. The angles are in radians. We will apply the VBA Sin function to get the Sine values.

- Copy the codes below and see the results in column C.

```
Sub Tan_Radian()
Dim xCell As Range
'Apply For Loop in a Range with Sin Function
For Each xCell In Range("B4:B9")
xCell.Offset(0, 1) = Sin(xCell.Value)
Next xCell
End Sub
```

**Example #2: Get Value for Sin Angle with Degree**

Now, we will want to get the sine values for degree angles. But the fact is that the VBA Sin function takes the argument as a radian unit by default. So, we need to convert the degree values into radians and calculate the sine values. We will do this by applying the VBA codes below.

- Copy the codes below and see the results in column C.

```
Sub Tan_Degree()
Dim xDegree As Range
Dim rad_to_deg As Range
Dim xCell As Range
Set xDegree = Range("B4:B9")
'Apply For Loop in a Range to convert degrees into radian
For Each xDegree In Range("B4:B9")
xDegree.Offset(0, 0) = (xDegree * Application.Pi) / 180
Next xDegree
'Apply For Loop in a Range with Sin Function
For Each xCell In Range("B4:B9")
xCell.Offset(0, 1) = Sin(xCell.Value)
Next xCell
Set rad_to_deg = Range("B4:B9")
'Apply For Loop in a Range to convert degrees into radian
For Each rad_to_deg In Range("B4:B9")
rad_to_deg.Offset(0, 0) = (rad_to_deg * 180) / Application.Pi
Next rad_to_deg
End Sub
```

- See the results in column C with tangent values for the degree angles.

**Things to Keep in Mind**

- Since VBA already includes the Sin function, your project won’t need additional libraries or references.
- The argument “number” must be written in radians. You can use the VBA function “Application.WorksheetFunction.Radians” to change degrees to radians.

**Frequently Asked Questions**

**Q: Is it possible to use complex numbers with the Sin function?**

A: No, only real numbers can be used with the Sin function.

**Q: Can I determine a triangle’s angle using the Sin function given the lengths of its sides?**

A: No, you would need to use one of the other trigonometric functions, such as **Asin**, **Acos**, or **Atan**, to determine the angle of a triangle given the lengths of its sides.

**Conclusion**

From this article, you have learned how to use the VBA Sin function in Excel to determine the sine values for two different units (radian and degree). These, in our opinion, will improve your professional work life somehow. If you have any additional questions, kindly post them in the comment section below. You will answer by offering solutions from the Solved Excel research department. Stay safe and get connected with us!