Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refering to another closed workbook 2

Status
Not open for further replies.

Yogi39

Technical User
Jun 20, 2001
273
CA
how do I refer to sheet 1
range D1
of workbook Test
residing in C:\johnny

and assign to variable Data ?
 
Perhaps I am misinterpreting your query to be too simplistic?


='C:\Johny\[test.xls]Sheet1'!$D$1

AshB
 
will that work in a macro or just as a cell formula, I would like to incorporate in some VB macro I'm building...:)
 
thinking about a simple solution, you could open the spreadsheet in the VB macro and then close it once you have picked the information you are refering to. Eg.

Workbooks.Open Filename:="C:\Johny\test.xls
Sheets("Sheet1").Select
Range("D1").Select

and then do what you will to the selected cell!

To then auto close the 'test' spreadsheet you could use

Windows("test.xls").Activate
ActiveWindow.Close


this may help, but there may be another way of refering to the external source without actually opening it?

AshB
 
I got this to work and I'm sure there is a way like you say to do this without actualy opening the Workbook.
Thanks again for teh help ! :)


Code:
Workbooks.Open Filename:="C:\Johnny\Test.xls"
d = Workbooks("Test.xls").Sheets("Sheet1").Range("$D$1").Value
Workbooks("Test.xls").Close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top