Trying to get this to generate the Fibonacci sequence from 0 to that whatever number the user inputs and siplay the result in a messagebox. Very lost.
Sub Fib()
Dim Fibonacci As Variant
Dim n As Integer
n = InputBox("Enter a number")
If (n <= 0) Then
Fibonacci = 0
ElseIf (n = 1) Then
Fibonacci = 1
Else
Fibonacci = Fibonacci(n - 1) + Fibonacci(n - 2)
End If
MsgBox (Fibonacci)
End Sub
Sub Fib()
Dim Fibonacci As Variant
Dim n As Integer
n = InputBox("Enter a number")
If (n <= 0) Then
Fibonacci = 0
ElseIf (n = 1) Then
Fibonacci = 1
Else
Fibonacci = Fibonacci(n - 1) + Fibonacci(n - 2)
End If
MsgBox (Fibonacci)
End Sub