ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I get the value of a cell in a un-opened workbook ? (https://www.excelbanter.com/excel-programming/325332-how-can-i-get-value-cell-un-opened-workbook.html)

Oasis

How can I get the value of a cell in a un-opened workbook ?
 
Thank you.

Tom Ogilvy

How can I get the value of a cell in a un-opened workbook ?
 
='[C:\My folder\My File.xls]Sheet3'!A1

You can put that formula in a cell, then replace it with the value returned
(fastest approach). Another:

http://www.j-walk.com/ss/excel/tips/tip82.htm
VBA Function to Get a Value From a Closed File
from John Walkenbach's site.


--
Regards,
Tom Ogilvy


"Oasis" wrote in message
...
Thank you.




K Dales[_2_]

How can I get the value of a cell in a un-opened workbook ?
 
There are several options:
1) Use a linked cell in the new worksheet. General form of the formula
would be:
='Link File.xls'!$A$1 (or whatever cell you want)
If you need to use this value for further calculations, just use the value
in the Range.
2) Open the book (hidden, if desired) and read the cell value using
Automation:
Dim LinkBook as Workbook
Set LinkBook = Workbooks.Open("Link File.xls")
LinkedCellVal = LinkBook.Sheets("LinkSheet").Range("$A$1").Value
LinkBook.Close
Set LinkBook = Nothing
3) Use a database query (either MSQuery or ADO methods in VBA) to read the
value from the closed book. Too complex for a quick explanation, search the
knowledge base/MSDN library for more info.
4) Use DDE (Dynamic Data Exchange) - also a complex subject, will have to
refer you again to MSDN library.

Best way depends on tradeoff of complexity/flexibility



"Oasis" wrote:

Thank you.



All times are GMT +1. The time now is 10:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com