我正在尝试使用代码
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
但收到#VALUE!使用时如下图:
目标 ='C:\Temp[pulltest.xlsx]Sheet1'!$A$1
参数 C:\Temp\ pulltest.xlsx Sheet1 A1
函数 =getvalue(B3,B4,B5,B6)
我在 Windows 7 中使用 Excel2010。
感谢任何帮助