
11.03.2013, 15:17
|
|
Забанен
|
|
Регистрация: 06.10.2012
Сообщений: 652
Репутация: 7 [+/-]
|
|
кто - нибудь знает, как в VBA использовать Averange для проверки расчетов
Скрытый текст - рекусия: Option Explicit
Type trade
id As Integer
texta As String
textb As String
textc As String
textd As String
texte As String
End Type
Public Sub asp()
Dim a(0 To 11) As trade, i%, d!, y%, N%, p%, textd%, texte%
For i = 0 To 11
a(i).id = Cells(3 + i, 1)
a(i).texta = Cells(3 + i, 2)
a(i).textb = Cells(3 + i, 3)
a(i).textc = Cells(3 + i, 4)
a(i).textd = Cells(3 + i, 5)
a(i).texte = Cells(3 + i, 6)
Next i
For i = 0 To 11
Cells(3 + i, 7) = a(i).id
Cells(3 + i, 8) = a(i).texta
Cells(3 + i, 9) = a(i).textb
Cells(3 + i, 10) = a(i).textc
Cells(2 + i, 11) = a(i).textd
Cells(2 + i, 12) = a(i).texte
Next i
For i = 0 To 11
textd = factorial(i)
Cells(3 + i, 5) = textd
Next i
For i = 0 To 11
Cells(3 + i, 5) = textd
textd = Fibonacci(i)
Cells(3 + i, 6) = textd
Next i
End Sub
Function factorial(N As Integer) As Integer
If N = 0 Then
factorial = 1
Else
factorial = N - factorial(N - 1)
End If
End Function
Function Fibonacci%(N%)
If N <= 1 Then
Fibonacci = 1
Else
Fibonacci = Fibonacci(N - 1) + Fibonacci(N - 1)
End If
End Function
Необходимо найти сумму в Cells(2 + i, 11) = a(i).textd
Cells(2 + i, 12) = a(i).texte при помощи рекурсии
|