No idea what SplineInterpolution() is supposed to do, but Google is your friend. There is an TREND() function that you could look at
Capture2.JPG
Some sugguestions
1. 'i' is more common than 'l' so I changed to 'i'
2. Long is recommended over Integer
3. If you don't explicitly Dim each variable, they default to Variant
Dim rt1 As Double, rt2 As Double
Option Base 1
Option Explicit
Function ForwardCurve(dblTime As Double, Term As Variant, SpotRates As Variant) As Variant
'Term and SpotRates are variant data type
Dim i As Long ' <<<<<<<<<<
Dim vecForwardRates() As Double
ReDim vecForwardRates(SpotRates.Count - 1)
'Create forward rate curve and fill vecForwardRates()
i = 1
For i = 1 To UBound(vecForwardRates)
vecForwardRates(i) = ForwardRate(dblTime, dblTime + Term(i), Term, SpotRates)
Next i
ForwardCurve = Application.WorksheetFunction.Transpose(vecForwardRates)
End Function
Private Function ForwardRate(dbt1 As Double, dbt2 As Double, rngTerm As Variant, rngMid As Variant) As Variant
Dim rt1 As Double, rt2 As Double ' <<<<<<<<<<<<
'find rt1, rt2 (appropriate interpolated rates) using spline interpolation method
rt1 = SplineInterpolation(dbt1, rngTerm, rngMid)
rt2 = SplineInterpolation(dbt2, rngTerm, rngMid)
'calculate forward rate f(rt1,rt2)
ForwardRate = rt2 * (dbt2 / (dbt2 - dbt1)) - rt1 * (dbt1 / (dbt2 - dbt1))
End Function
The error message and the highlight is pretty clear that 'i' is not defined
That's the reason I always use Option Explicit, since the macro would run, but the answers would be wrong (I'll take all the help I can get)
Capture.JPG