I'm creating a user defined function and input values from a range of cells (like =sk_test(A1:a5)), do calculations with those values, return an array with values in cells. To use it, I highlight the cells that will hold return values, enter function call (like =sk_test(A1:a5)) and CTRL+SHIFT+RETURN. The following code is giving me errors. Thanks.
Regards, Steve
Function sk_test(data1 As Range) As Variant
Dim c As Range
Dim aa() As Double
Dim i, npt As Integer
Dim data2 As Variant
data2 = data1
npt = UBound(data2)
Redim aa(1 To npt)
i = 1
For Each c In data1
aa(i) = c.Value * 10 + 99 ' example of calcuations
i = i + 1
Next c
i = 1
For Each c In data2
c.Value = aa(i)
i = i + 1
Next c
sk_test = data2
End Function

c.Value = aa(i)- you can't modify cells in UDF (in normal way)