Answer the question
In order to leave comments, you need to log in
How to create a macro for calculating the sum of Fibonacci numbers?
You need to create a table with two columns. Let there be 10 lines in total. The first column is the serial number. The second column is a sequence of fibonacci numbers. After generating the table, you need to calculate the sum of a series of fibonacci numbers. Please help me with a solution.
Sub CreateTable()
'переменная для присвоения количества строк
Dim a As Long
a = Cells(10, 2).CurrentRegion.Rows.Count
'Добавляем строку заголовков
Cells(1, 1).EntireRow.Insert
'Указываем названия граф
Cells(1, 1) = "№ п/п"
Cells(1, 2) = "Значение"
'Добавляем сетку
Range(Cells(1, 1), Cells(a + 10, 2)).Borders.LineStyle = True
'Выделяем заголовки жирным шрифтов и применяем автоподстройку ширины столбцов
With Range(Cells(1, 1), Cells(1, 2))
.Font.Bold = True
.EntireColumn.AutoFit
End With
End Sub
Answer the question
In order to leave comments, you need to log in
Why is there a macro here? Formulas in a few seconds are done (column C - the sum of the first numbers):
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question