我有一个UDF,它基于一堆输入变量进行计算。我试图使UDF创建一个包含有关这些变量的信息的单元格注释,但我只是得到了#VALUE!错误。
这就是我想要做的:
Function profit(income As Single, loss As Single) As Single
Dim cell As Range
cell = ActiveCell
profit = income - loss
call create_comment(cell, income, loss)
End function
调用子:
Private Sub create_comment(cell As Range, income As Single, loss As Single)
cell.ClearComments
cell.Addcomment "income =" & income & "loss =" & loss
End Sub
感谢所有帮助!
答案 0 :(得分:0)
我那样改变了你的功能
Function profit(income As Single, loss As Single, cell As Range) As Single
'Dim cell As Range
'cell = ActiveCell
profit = income - loss
Call create_comment(cell, income, loss)
End Function
然后在这样的函数调用中输入活动单元格
=profit(1000,10,H10)