This is my original code. Thanks
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
Sub TestGetValue2()
p = "C:\Excel Test"
f = "Terry 2.xlsx"
s = "Sheet1"
a = "D6:G9"
Range("A1:D6") = GetValue(p, f, s, a)
End Sub
Bookmarks