[英]Excel 2016 mac vba evaluate error
I am using Excel v16.9 on a mac running 10.13.3 and am trying to use the Evaluate function but it returns error Error 2015
.我在运行 10.13.3 的 Mac 上使用 Excel v16.9 并尝试使用 Evaluate 函数,但它返回错误
Error 2015
。
The line that causes the error is:导致错误的行是:
temp = Evaluate(GetWebDataTest("https://query2.finance.yahoo.com/v10/finance/quoteSummary/IBM?modules=assetProfile", 269, 150))
When I step through the code, GetWebDataTest
is correctly evaluated but when the function ends the value is not returned to the variable test
instead it shows Error 2015
当我逐步执行代码时,
GetWebDataTest
被正确评估,但是当函数结束时,该值不会返回到变量test
而是显示Error 2015
The value that GetWebDataTest
returns is: GetWebDataTest
返回的值是:
"sector":"Technology","longBusinessSummary":"International Business Machines Corporation provides information technology (IT) products and services wo
Is this a bug with the Mac version of Excel or I am doing something wrong.这是 Mac 版 Excel 的错误还是我做错了什么。
Update:更新:
Upon further investigation of the problem, I have narrowed it down to Evaluate
not being able to return a string.在进一步调查问题后,我已将其范围缩小到
Evaluate
无法返回字符串。 Consider the following code:考虑以下代码:
temp = Evaluate(RetText())
temp1 = Evaluate(RetNo())
Public Function RetText() As String
RetText = "Te"
End Function
Public Function RetNo()
RetNo = 5
End Function
When run, temp
throw an error - Error 2029
whereas temp1
correctly is assigned the value 5.运行时,
temp
抛出错误 - Error 2029
而temp1
正确分配了值 5。
It looks as though Evaluate
will fail if the resulting function tries to return a string.如果结果函数试图返回一个字符串,它看起来好像
Evaluate
将失败。
Evaluate tries to execute whatever it is given as a formula - so it thinks TE should be a defined Name which it can't find. Evaluate 尝试执行它作为公式给出的任何内容 - 因此它认为 TE 应该是它无法找到的已定义名称。
Try this:试试这个:
Public Function RetText() As String
RetText = "=""Te"""
End Function
or this或者这个
Public Function RetText() As String
RetText = """Te"""
End Function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.