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

asked 2019-09-03 01:49:41 +0100

JackZed gravatar image

updated 2019-09-03 02:31:05 +0100

Ratslinger gravatar image

Edited by @Ratslinger for clarity:

Function INFLATION_ADJUSTED(optional x(),optional y(),optional 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 Future_Year
            Inflation_Rate = (Amplitude*SIN(Period*(i)+H)+V)
            r = AMT*(1-Inflation_Rate/100)
        Next i

        INFLATION_ADJUSTED = r
    End Function
edit retag flag offensive close merge delete

Comments

Delta = (y(1,1)-y(0,1)) gives the inadmissible data type: Index out of defined Range error. when I Try to Call the function in my spreadsheet.

JackZed gravatar imageJackZed ( 2019-09-03 01:51:14 +0100 )edit

Hello,

This seems to have been discussed already in a past post here -> Hello, I have a libreoffice basic programming question.

Ratslinger gravatar imageRatslinger ( 2019-09-03 05:10:56 +0100 )edit