I’m trying to send an array of values INTO a user defined function, do a little math on it, and then send the resulting array back to the caller. The caller in this case is an array formula in an excel cell. I can get it to build an array after the math, but I can’t get it to pass the resulting array back to the formula. The following snippet is a simple version of the code. Here I am building the incoming array in the macro, but same difference at the end. The outgoing Oil_spgr variable never seems to contain the full, final array.
Function Oil_spgr()
Dim Spgr_Result() As Variant
ReDim Spgr_Result(1 To 4)
Temp = 480
For i = 1 To 4
' Oil_spgr(i) = -0.0002265 * Temp + 0.886023 … most direct method of storing new array
Spgr_Result(i) = -0.0002265 * Temp + 0.886023
Oil_spgr(i) = Spgr_Result(i) ' … store new array after building phantom array, the phantom array builds-up ok, but Oil_spgr won’t
Temp = Temp + 10
Next i
End Function
Bookmarks