J
John James
O.K. Here's code which will extract data from a specified cell in
closed file. Many thanks to Randy Harmelink:
Private Function GetXLSData(sFile As String, sSheet As String, sCel
As
String)
Set oDB = CreateObject("ADODB.Recordset")
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFile & ";" & _
"Extended Properties='Excel 8.0;HDR=No'"
sSQL = "SELECT * From [" & sSheet & "$" & sCell & ":" & sCell & "]"
oDB.Open sSQL, sConn, 3, 3, 1
GetXLSData = oDB.Fields.Item(0).Value
oDB.Close
Set oDB = Nothing
End Function
Then, his formula is:
=GetXLSData("Lists.xls", "Sheet1","B2")
Refer:
http://www.excelforum.com/showthread.php?t=531126
http://tinyurl.com/jvrw
closed file. Many thanks to Randy Harmelink:
Private Function GetXLSData(sFile As String, sSheet As String, sCel
As
String)
Set oDB = CreateObject("ADODB.Recordset")
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFile & ";" & _
"Extended Properties='Excel 8.0;HDR=No'"
sSQL = "SELECT * From [" & sSheet & "$" & sCell & ":" & sCell & "]"
oDB.Open sSQL, sConn, 3, 3, 1
GetXLSData = oDB.Fields.Item(0).Value
oDB.Close
Set oDB = Nothing
End Function
Then, his formula is:
=GetXLSData("Lists.xls", "Sheet1","B2")
Refer:
http://www.excelforum.com/showthread.php?t=531126
http://tinyurl.com/jvrw