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.
- Using Excel VBA code
- 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.
Fibonacci Sequence Number GeneratorVisual Basic1234567891011121314151617181920212223Sub Generate_Fibonacci_Series()Dim n1 As Double, n2 As Double, nTot As DoubleDim iRow As Double, Fibonacci As Doublen1 = ThisWorkbook.Sheets(1).Cells(1, 1) 'Enter First Number in Seriesn2 = ThisWorkbook.Sheets(1).Cells(2, 1) 'Enter Second Number in SeriesnTot = ThisWorkbook.Sheets(1).Cells(1, 3) 'Enter Total Numbers in SeriesiRow = 2'Generate Fibonacci SeriesWhile (nTot - 2) > 0Fibonacci = n1 + n2ThisWorkbook.Sheets(1).Cells(iRow + 1, 1) = Fibonacci'Get Next numbers to generate Fibonacci Seriesn1 = ThisWorkbook.Sheets(1).Cells(iRow, 1)n2 = ThisWorkbook.Sheets(1).Cells(iRow + 1, 1)iRow = iRow + 1nTot = nTot - 1WendMsgBox "Fibonacci Numbers Generated - Code From Officetricks.com"End Sub
- Open a new Excel workbook.
- Enter ‘0’ in A1, ‘1’ in A2. ’10’ in C3.
- Press Alt+F11 to view VB editor.
- Copy paste below code.
- Press F5 to execute the code.
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.
- Type ‘0’ in Cell A1.
- Type ‘1’ in Cell A2.
- Enter ‘=A1 + A2’ in Cell A3.
- Select cell A3.
- 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.
Fibonacci Sequence Number Generator – Excel Easy Trick