### Why does My Macro Function give error: Inadmissible value or data type. Index out of defined range.

Function INFLATION_ADJUSTED(optional x(),optional y(),optional ~~AMT) ~~AMT, optioanal Future_Year) as double
REM predicts the amount adjusted for inflation
dim Amplitude as double
dim Delta as double
dim H as double
dim V as double
dim Period as double
dim r as double
dim Inflation_Rate as double

```
Delta = ((y(1,1)-y(0,1)))
Amplitude = scr(y(0,1)^2 - Delta^2)
Period = PI()/UBound(x)
H = ASIN(y(0,1)/Period)
V = 0
For n = 0 to x
V = V + y(n,1)/UBound(x)
Next n
For i = 0 to
```~~UBound(x)
~~Future_Year
Inflation_Rate = (Amplitude*SIN(Period*(i)+H)+V)
r = AMT*(1-Inflation_Rate/100)
Next i
INFLATION_ADJUSTED = r

End Function