I am writing a UDF to return array variants given the UDF subscript values. The UDF is below:
I am receiving the "subscript out of range error on the last line:
The Function name is a variant as is LogArray. LogArray is Redim (1 to numberobs) whereas LogPriceData is not specified. What might be causing this error?
Code:
Function LogPriceData(Arr As Variant, numberObs As Integer) As Variant
Dim yy As Integer
Dim Array1() As Variant: ReDim Array1(1 To numberObs)
Dim Array2() As Variant: ReDim Array2(1 To numberObs)
Dim LogArray As Variant: ReDim LogArray(1 To numberObs)
ActiveWorkbook.Sheets("ActiveSheet").Activate
For yy = 1 To numberObs
Array1(yy) = Arr(numberObs, 2)
Array2(yy) = Arr(yy, 2)
LogArray(yy) = Application.WorksheetFunction.Log(Array2(yy), Array1(yy))
Next yy
LogPriceData = LogArray(yy)
End Function
I am receiving the "subscript out of range error on the last line:
Code:
LogPriceData = LogArray(yy)
The Function name is a variant as is LogArray. LogArray is Redim (1 to numberobs) whereas LogPriceData is not specified. What might be causing this error?