Reputation: 11
I am creating a function that takes a cell and a range of cells to create an array. The first four numbers of this array are used to perform some calculations. At the end, I want to return the sum of these to the cells. On the debug, I add a watch to the sum A+B+C+D and the result show up perfectly. However, it does not return the value to the cell when I call the function in the worksheet. Why is this?
Public Function getFone(temp As Long, coeffs As Range) As Double
Dim coeffArray As Variant
Dim A As Double
Dim B As Double
Dim C As Double
Dim D As Double
coeffArray = coeffs.Value
A = ((coeffArray(1, 1)) * (temp))
B = ((coeffArray(1, 2) / 2) * (temp * temp))
C = ((coeffArray(1, 3) / 3) * (temp * temp * temp))
D = ((coeffArray(1, 4) / 4) * (temp * temp * temp * temp))
getFone = (A + B + C + D)
End Function
Upvotes: 1
Views: 154
Reputation: 1265
The code works if the range is four horizontal cells and the temp parameter and the range contain numerics. So the potential issues that might trigger a #Value result are:
Upvotes: 1