A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

calculate a formula instead of returning text



 
 
Thread Tools Display Modes
  #21  
Old April 8th, 2006, 10:55 AM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: n/a
Default calculate a formula instead of returning text


O.K. Here's code which will extract data from a specified cell in a
closed file. Many thanks to Randy Harmelink:

Private Function GetXLSData(sFile As String, sSheet As String, sCell
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/jvrwv


--
John James
------------------------------------------------------------------------
John James's Profile: http://www.excelforum.com/member.php...o&userid=32690
View this thread: http://www.excelforum.com/showthread...hreadid=527258

  #22  
Old April 9th, 2006, 11:28 PM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: n/a
Default calculate a formula instead of returning text

John James wrote...
O.K. Here's code which will extract data from a specified cell in a
closed file. Many thanks to Randy Harmelink:

Private Function GetXLSData(sFile As String, sSheet As String, _
sCell 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")

....

Several caveats. Most significant, the ADO DLL must be installed. Not
sure if this it's installed by default by (or even included with)
Standard versions of Office or standalone Excel. Second, this works for
single cell sCell, but not for multiple cell ranges, so limited
functionality.

Other alternatives are given in the following article in the archives.

http://groups.google.com/group/micro...443753560f0075

(or http://makeashorterlink.com/?B34B15DCC ).

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Feedback on table setup Little Penny Database Design 1 December 28th, 2005 11:32 AM
Is Access even the right idea? BMB New Users 19 November 21st, 2005 08:01 PM
Creating dynamic cross reference links in a Word document torajudo General Discussion 4 October 25th, 2005 03:51 PM
Query for 'confirmation' rogge Running & Setting Up Queries 8 April 19th, 2005 03:26 PM
Access reports with a horizontal line after each record??? Bill via AccessMonster.com Setting Up & Running Reports 6 March 9th, 2005 04:51 PM


All times are GMT +1. The time now is 06:49 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.