×

Excel VBA Sin Function

VBA Sin Function: The Sin function in VBA returns the sine value for a supplied angle.

Syntax

Sin (Number)

Parameter

Number (required) –This parameter represents the angle (in radians) to calculate the sine value.

Return

This function returns the sine value for a supplied angle.

Example 1

Sub SinFunction_Example1()
 ' Calculating the sine for the specified number.
 Dim sin_val1 As Double
 Dim sin_val2 As Double
 Dim sin_val3 As Double
 sin_val1 = Sin(90)
 ' The variable sin_val1 will return value 0.893996663600558. 
 Cells(1, 1).Value = sin_val1
 sin_val2 = Sin(0)
 ' The variable sin_val2 will return value 0.
 Cells(2, 1).Value = sin_val2
 sin_val3 = Sin(3.14159265358979)
 ' The variable sin_val3 will return value 3.23108510433268E-15.
 Cells(3, 1).Value = sin_val3
 End Sub 

Output

0.893996664
0
3.23E-15
VBA Sin Function

Example 2

Sub SinFunction_Example2()
 ' Calculating the sine for the specified number.
 Dim sin_val As Double
 sin_val = Sin(0.785398163397448)
 ' The variable sin_val will return value 0.707106781186547.
 Cells(1, 1).Value = sin_val
 End Sub 

Output

0.707106781186547

VBA Sin Function

Example 3

Sub SinFunction_Example3()
 ' Calculating the sine for the specified number.
 Dim sin_val As Double
 Const pi = 3.14159265358979
 ' Converting 60 degrees to radians by multiplying by pi/180.
 sin_val = Sin(60 * pi / 180) 
 ' The variable sin_val will return radina 0.866025403784438.
 Cells(1, 1).Value = sin_val
 End Sub 

Output

0.866025403784438

VBA Sin Function

Related Topics

Excel VBA IsDate Function

VBA IsDate Function: The IsDate function in VBA returns a Boolean value indicating whether the given expression is interpreted as a VBA Date or not. Syntax IsDate (Expression) Parameter Expression (required) – This parameter...

1 minute read.

Excel VBA CInt Function

VBA CInt Function: The VBA Cint function converts the specified expression into an Integer. Syntax Cint (Expression) Parameter Expression (required) – This parameter represents the expression that you want to convert to an Integer wherein...

1 minute read.

Excel VBA Weekday Function

Excel VBA Weekday Function: The TimeValue function in VBA returns an integer (1 to 7), signifying the day of the week for the specified date. Syntax Weekday (Date, [FirstDayOfWeek]) Parameter Date (required) – This parameter...

2 minutes read.

Excel VBA MessageBox

Message Box The MsgBox in Excel VBA is a dialog box used to inform the users of your program by showing a custom message or get some necessary inputs such as Yes/No or...

4 minutes read.

Excel VBA DateValue Function

The DateValue function in VBA returns a VBA Date from the given String representation of a date wherein the time information is ignored. It is unable to interpret dates that include the...

1 minute read.

Excel VBA : With End-with Constructs

With End-with Constructs The With-End With construct enables the user to perform multiple operations on a single object. If you are going to perform several different actions on the same object and typing the same...

4 minutes read.

Excel VBA Hour Function

The hour function in VBA returns the hour element for the specified time. Syntax Hour (Time) Parameter Time (required) – This parameter represents the time. Return This function returns the hour element for the specified time. Example 1 Sub HourFunction_Example1() ...

1 minute read.

Excel VBA StrComp Function

VBA StrComp Function: The StrComp function in VBA compares two strings and returns an integer value displaying the result of the comparison. Syntax StrComp (String1, String2, [Compare]) Parameter String1 (required)- This parameter represents the first string to...

2 minutes read.

Excel VBA Replace Function

VBA Replace Function: The Replace function in VBA searches for a substring within the specified string and replaces its occurrences with a second substring. Syntax Replace (Expression, Find, Replace, [Start], [Count], [Compare]) Parameter Expression (required) – This parameter represents...

2 minutes read.

VBA Object Required

What is Object Required Error? VBA Object Required is a run time error which occurs when the user does not define a valid object qualifier, or the assigned object doesn’t exist in the...

6 minutes read.

Excel VBA StrConv Function

The StrConv function in VBA converts a string into a specified format. Syntax StrConv (String, Conversion, [LocaleID]) Parameter String (required) – This parameter represents the string to be converted. Conversion (required) – This parameter specifies the type of conversion. It can...

1 minute read.

Excel VBA Sqr Function

VBA Sqr Function: The Sqr function in VBA returns the square root for the specified number. Syntax Sqr (Number) Parameter Number (required) – This parameter represents a positive numeric value that you want to calculate...

1 minute read.

VBA Color Index Property

What is Color Index Property? The Excel VBA Color Index is used to change the color for the cell or range of cells or text (located under the Font section). It sets the color...

5 minutes read.

Excel VBA IsMissing Function

VBA IsMissing Function: The IsMissing function in VBA checks if any parameter to a procedure is missing or not. It returns a Boolean value True if the specified parameter has not been...

1 minute read.

Excel VBA Conditional Statement

Conditional Statement in VBA Excel Conditional Statements in Excel VBA are one of the most powerful and useful features in programming, this will give you to perform comparisons to decide or...

2 minutes read.

Excel VBA Fix Function

VBA Fix Function: The Fix function in VBA truncates the given number to an integer and returns the rounded off integer number. This function both positive and negative numbers to zero. Syntax Fix...

1 minute read.

Excel VBA Chr Function

VBA Chr Function: The Chr function in VBA returns the character equivalent to a supplied character code between 0 and 255. Syntax Chr (CharCode) Parameter CharCode (required) – This parameter represents the character code for...

1 minute read.

VBA Creating, Displaying, Uploading UserForms

UserForm is a customized interface and acts as a VBA container and can add various controls as per the required functionality, each of which has certain usage and related properties. You can...

4 minutes read.

Miscellaneous Exercise of conditional statements and Loop

We have the already worked with syntax and examples of conditional statements and loops in the previous tutorials. In this tutorial, we will learn how to work with both together.  We will explain...

3 minutes read.

Excel VBA FormatDateTime Function

VBA FormatDateTime Function: The FormatDateTime function in VBA returns the result as a string after applying a date and/or time format to the supplied expression. Syntax FormatDateTime (Expression, [NamedFormat]) Parameter Expression (specified) – This parameter...

2 minutes read.