Hi
I have a user function which defines two vectors (as arrays) and multiplies them together to get a single value.
This works fine and if I stop there the function will display this value in the cell, no problem.
However, if I want to do anything else with the value within the function e.g. add or subtract another number, then I get a #VALUE! error in the cell
I assume this is because of some incompatibility with variable types, but can't seem to find a way to make it work.
Any help would be much appreciated
Function abc(x)
Dim theta As Variant, Xvec As Variant
theta = Array(1, 2, 3, 4, 5, 6)
Xvec = Array(1, 2, 3, 4, 5, 6)
rownum = Application.Caller.Row
Xvec(0) = 1
Xvec(1) = Cells(rownum, 2)
Xvec(2) = Cells(rownum, 3)
Xvec(3) = Cells(rownum, 4)
Xvec(4) = Cells(rownum, 5)
Xvec(5) = Cells(rownum, 6)
theta = Application.Transpose(theta)
Dim Z As Variant
Z = Application.MMult(Xvec, theta)
abc = Z + 1
End Function
Bookmarks