【发布时间】:2014-12-30 19:21:31
【问题描述】:
我在使用返回包含长字符串(>256 个符号)的数组的 UDF 时遇到 #VALUE 错误。
示例代码:
Function longString() As Variant
Dim res(1 To 1, 1 To 2)
res(1, 1) = "hellohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\nhellohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\nhellohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\nhellohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhellohh\n"
res(1, 2) = "world"
longString = res
End Function
在单元格中调用longString()作为数组公式时,单元格出现#Value错误,但通过调试,longString()返回没有错误。
我该如何解决这个问题?
【问题讨论】:
-
您的代码不会在我的机器上引发任何错误 (Excel 2010)。你是哪个版本的?
-
@silentsurfer 您是否在工作表单元格中输入了 UDF 作为公式?它在 Excel 2007 的该单元格中返回
#VALUE!错误。