JonK
11-29-2014, 07:22 AM
Found This:
Sub Sine()
Option Explicit
Sub SinXSeriesExpansion()
Dim M As Long, N As Long, X As Double, SineX As Double
X = InputBox("What is X?")
M = InputBox("How many terms?")
If IsNumeric(M) And M > 0 Then
SineX = 0
On Error GoTo OverFlow
For N = 0 To M \ 1
SineX = SineX + ((-1) ^ (N) * X ^ (2 * N + 1)) / Evaluate("Fact(" & 2 * N + 1 & ")")
Range("A" & N + 1) = SineX
Next
MsgBox SineX
Else
MsgBox "Need the number of terms to be greater than zero!"
End If
Exit Sub
OverFlow:
MsgBox "Too many terms - try fewer terms", , "OverFlow Error!!"
End Sub
Cannot make it run
Says Option Explicit is Invalid Inside Procedure Help says remove it so I did, and it says compile error Expected End Sub I am in over my head
Sub Sine()
Option Explicit
Sub SinXSeriesExpansion()
Dim M As Long, N As Long, X As Double, SineX As Double
X = InputBox("What is X?")
M = InputBox("How many terms?")
If IsNumeric(M) And M > 0 Then
SineX = 0
On Error GoTo OverFlow
For N = 0 To M \ 1
SineX = SineX + ((-1) ^ (N) * X ^ (2 * N + 1)) / Evaluate("Fact(" & 2 * N + 1 & ")")
Range("A" & N + 1) = SineX
Next
MsgBox SineX
Else
MsgBox "Need the number of terms to be greater than zero!"
End If
Exit Sub
OverFlow:
MsgBox "Too many terms - try fewer terms", , "OverFlow Error!!"
End Sub
Cannot make it run
Says Option Explicit is Invalid Inside Procedure Help says remove it so I did, and it says compile error Expected End Sub I am in over my head