Ask LibreOffice - RSS feedhttps://ask.libreoffice.org/en/questions/Questions and answers for LibreOfficeenTue, 03 Sep 2019 05:10:56 +0200Why does My Macro Function give error: Inadmissible value or data type. Index out of defined range.https://ask.libreoffice.org/en/question/207217/why-does-my-macro-function-give-error-inadmissible-value-or-data-type-index-out-of-defined-range/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 FunctionTue, 03 Sep 2019 01:49:41 +0200https://ask.libreoffice.org/en/question/207217/why-does-my-macro-function-give-error-inadmissible-value-or-data-type-index-out-of-defined-range/Comment by Ratslinger for <p>Edited by <a href="/en/users/19488/ratslinger/">@Ratslinger</a> for clarity:</p>
<pre><code>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
</code></pre>
https://ask.libreoffice.org/en/question/207217/why-does-my-macro-function-give-error-inadmissible-value-or-data-type-index-out-of-defined-range/?comment=207226#post-id-207226Hello,
This seems to have been discussed already in a past post here -> [Hello, I have a libreoffice basic programming question.](https://ask.libreoffice.org/en/question/167805/hello-i-have-a-libreoffice-basic-programming-question/)Tue, 03 Sep 2019 05:10:56 +0200https://ask.libreoffice.org/en/question/207217/why-does-my-macro-function-give-error-inadmissible-value-or-data-type-index-out-of-defined-range/?comment=207226#post-id-207226Comment by JackZed for <p>Edited by <a href="/en/users/19488/ratslinger/">@Ratslinger</a> for clarity:</p>
<pre><code>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
</code></pre>
https://ask.libreoffice.org/en/question/207217/why-does-my-macro-function-give-error-inadmissible-value-or-data-type-index-out-of-defined-range/?comment=207218#post-id-207218Delta = (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.Tue, 03 Sep 2019 01:51:14 +0200https://ask.libreoffice.org/en/question/207217/why-does-my-macro-function-give-error-inadmissible-value-or-data-type-index-out-of-defined-range/?comment=207218#post-id-207218Answer by Ratslinger for <p>Edited by <a href="/en/users/19488/ratslinger/">@Ratslinger</a> for clarity:</p>
<pre><code>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
</code></pre>
https://ask.libreoffice.org/en/question/207217/why-does-my-macro-function-give-error-inadmissible-value-or-data-type-index-out-of-defined-range/?answer=207225#post-id-207225Hello,
It may help to know how you are calling the function. From what I see there is no `0` in that array & that creates the error.
Calling with `$A$1:$B$2` A1 = 1,1 and B2 = 2,2.
There is also nothing in the code if optional parameters are missing and a misspelled `optioanal` by Future_Year.
Just an initial glance. Don't really have the knowledge of what else your code is supposed to do.
You may want to refer to Open Office Macros Explained by Andrew Pitonyak - PDF here -> [OOME](http://www.pitonyak.org/OOME_3_0.pdf)Tue, 03 Sep 2019 05:00:53 +0200https://ask.libreoffice.org/en/question/207217/why-does-my-macro-function-give-error-inadmissible-value-or-data-type-index-out-of-defined-range/?answer=207225#post-id-207225