由于某些原因,自定义函数似乎不在Excel中运行。我创建了下面的简单函数,但它总是返回零作为值,无论它是用作工作表函数还是从过程调用。任何人都知道我做错了什么,或者在某个地方有我失踪的设置?
Public Function Testthisout(number As Double) As Double
result = number * number
End Function
Public Sub TESTFUNCTION()
Dim number As Double
Dim result As Double
Application.Volatile (True)
number = 4
result = Testthisout(number)
MsgBox result
End Sub
答案 0 :(得分:3)
将您的功能更改为:
Public Function Testthisout(number As Double) As Double
result = number * number
Testthisout = result
End Function