我无法使用" getvalue"功能在vba。
Sub testgetvalue1()
Dim p As String
Dim t As String
Dim s As String
Dim a As String
p = "D:\Archive Mail"
t = "Excel_1"
s = "Sheet1"
a = "A1"
msgbox getvalue(p, t, s, a)
End Sub
它总是抛出错误名称"子或函数未定义"它突出了" getvalue" function.I假设代码没有问题,为什么我收到此错误消息?
...建议
此致 PRASHANT
答案 0 :(得分:0)
GetValue
不是预定义的函数,因此您需要自己定义它。也许您阅读了一篇定义并使用它的文章。 Here就是这样一篇文章,它定义如下:
Private Function GetValue(path, file, sheet, ref)
' Retrieves a value from a closed workbook
Dim arg As String
' Make sure the file exists
If Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
GetValue = "File Not Found"
Exit Function
End If
' Create the argument
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)
' Execute an XLM macro
GetValue = ExecuteExcel4Macro(arg)
End Function
将此信息包含在您的模块中,您应该准备好了。