title: UDF VBA producing zeros. No error values, just zeros. Can someone please check my code
body: <p>'VBA function is calculate the 1 year forward rate in 0.5, 1, 1.5 and 2 years etc. All results are zero; no error values, just zeros. Can anybody advise where I'm going wrong. Thanks</p>
  
  <pre><code>Function OneYearFwdRates(Mty As Range, Spots As Range) As Variant
  Dim Maturities()
  ReDim Maturities(Mty.Rows.Count)  'Mty is the range of maturities'
  Dim SpotRates()
  ReDim SpotRates(Spots.Rows.Count)  'Spots is the range of spot rates'
  Dim OYFR()                         'OYFR stands for One Year Forward Rates'
  ReDim OYFR(Spots.Rows.Count)
  Dim i
  
  For i = 2 To Spots.Rows.Count - 2
      OYFR(i) = (1 + SpotRates(i + 2)) ^ (Maturities(i + 2)) _
          / (1 + SpotRates(i)) ^ (Maturities(i)) - 1
  Next i
  OneYearFwdRates = OYFR
  
  End Function
  </code></pre>
  
  <p>Below is the spreadsheet. I want to fill the blue column titled Forward Rates, f(x,1), with the above code</p>
  
  <pre><code>                        Forward Rate
  Maturity    Spot Rate     f(x,1)
   0.00         0.0200    
   0.5          0.0218    
   1.0          0.0231    
   1.5          0.0243    
   2.0          0.0253    
   2.5          0.0261    
   3.0          0.0268    
   3.5          0.0273    
   4.0          0.0277    
   4.5          0.0281    
   5.0          0.0284    
   5.5          0.0287    
   6.0          0.0289    
   6.5          0.0291    
   7.0          0.0293    
   7.5          0.0295    
   8.0          0.0296    
   8.5          0.0298    
   9.0          0.0299    
   9.5          0.0300    
   10.0         0.0301    
   10.5         0.0302    
   11.0         0.0303    
   11.5         0.0303    
   12.0         0.0304    
   12.5         0.0304    
  </code></pre>