Fibonacci Sequence Number Generator – Excel Easy Trick

What is the Fibonacci Number Sequence?

Fibonacci series is a sequence of numbers. Any number in the list is a sum of last 2 numbers ahead of it (i.e., Last 2 preceding numbers).

This series can be generated in Excel using 2 methods.

  1. Using Excel VBA code
  2. Using Auto-fill & Sum Formula

In both methods, for a Fibonacci sequence, the first two numbers have to be explicitly mentioned. Sample series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 … n.

Fibonacci Sequence Tool

There is special formula to find the Nth number in a Fibonacci series. But, in this article, we are just going to look at how to generate the series with Excel Macro.

  1. Open a new Excel workbook.
  2. Enter ‘0’ in A1, ‘1’ in A2. ’10’ in C3.
  3. Press Alt+F11 to view VB editor.
  4. Copy paste below code.
  5. Press F5 to execute the code.
Sub Generate_Fibonacci_Series()
    Dim n1 As Double, n2 As Double, nTot As Double
    Dim iRow As Double, Fibonacci As Double
    n1 = ThisWorkbook.Sheets(1).Cells(1, 1) 'Enter First Number in Series
    n2 = ThisWorkbook.Sheets(1).Cells(2, 1) 'Enter Second Number in Series
    nTot = ThisWorkbook.Sheets(1).Cells(1, 3) 'Enter Total Numbers in Series
    iRow = 2
    'Generate Fibonacci Series
    While (nTot - 2) > 0
        Fibonacci = n1 + n2
        ThisWorkbook.Sheets(1).Cells(iRow + 1, 1) = Fibonacci
        'Get Next numbers to generate Fibonacci Series
        n1 = ThisWorkbook.Sheets(1).Cells(iRow, 1)
        n2 = ThisWorkbook.Sheets(1).Cells(iRow + 1, 1)
        iRow = iRow + 1
        nTot = nTot - 1
    MsgBox "Fibonacci Numbers Generated - Code From"
End Sub

Once executed, this will generate Fibonacci series in sheet1.

Fibonacci Series in Excel

This method used just the Sum formula & Auto-fill option. Using this we can generate any number of Fibonacci list in few minutes.

  1. Type ‘0’ in Cell A1.
  2. Type ‘1’ in Cell A2.
  3. Enter ‘=A1 + A2’ in Cell A3.
  4. Select cell A3.
  5. Drag the formula to N number of cells to get Fibonacci series.

We can change the first & second number to automatically get other Fibonacci numbers changed in order.

Leave a Reply