I am working with a User Defined Function to transform an array of nominal integer values to logarithms. I have the code below.
LogArray is a variant and I suspect this data type does not work with the integer values being fed into the worksheetfunction.
How can I build the array to hold log values?
LogArray is a variant and I suspect this data type does not work with the integer values being fed into the worksheetfunction.
How can I build the array to hold log values?
Code:
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'X This UDF converts an array of nominal values into an array of logarithmic values X
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Function LogPriceData(Arr As Variant, numberObs As Integer) As Variant
Dim yy As Integer
Dim Array1 As Integer
Dim Array2 As Integer
Dim LogArray As Variant
ActiveWorkbook.Sheets("ActiveSheet").Activate
Array1 = Application.WorksheetFunction.Index(Arr, 1, 2)
For yy = 1 To numberObs
Array2 = Application.WorksheetFunction.Index(Arr, yy, 2)
LogArray(yy) = Application.WorksheetFunction.Log(Array2, Array1)
Next yy
LogPriceData = logarray()
End Function