The code below works just fine for me but wanted to add: readonly:=true
Code: Select all
Public Function GetValue(P, F, S, ref)
'Retrieves a value from a closed workbook
Dim arg As String
'Make sure the file exists
If Right(P, 1) <> "\" Then P = P & "\"
If Dir(P & F, vbHidden) = "" Then
GetValue = "File Not Found"
Exit Function
End If
'Create the argument
arg = "'" & P & "[" & F & "]" & S & "'!" & _
range(ref).range("A1").Address(, , xlR1C1)
'Execute an XLM macro
GetValue = ExecuteExcel4Macro(arg)
End Function
John