I'm trying to make a UDF of mine work (in Excel 2003), and after debugging the problem appears to be summarized in this condensed version of my function:
Function btest(b_1 As Double) As Double
btest = 1
Worksheets("Sheet1").Range("A1").Value = b_1
'^this is the bit I want to work but doesn't^
End Function
This simulates my real function, which has a value assigned to it with no problems before the following cell output line which doesn't execute. I believe this is related to the #VALUE!
error I get as a return, even though I used a MsgBox
which showed that the function did have a numeric value.
Can anyone shed light on this please?
Also: what is the difference between
Worksheets("Sheet1").Cells(1, 1) = B
and
Sheets("Sheet1").Range("A1").Value = B
where B is some numerical value?
Thanks