ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   workbooks.open - another option (https://www.excelbanter.com/excel-programming/392162-workbooks-open-another-option.html)

Mona

workbooks.open - another option
 
I will be accessing several workbooks (test.xls, test1.xls, ...).

What is the syntax to "reference" workbook without having to open it?

thanks
-Mona

Set wbkTarget = Workbooks.open(Filename:="c:\ test.xls")
If wbkTarget Is Nothing Then
MsgBox "Can not open file"
Else
Set wksTarget = wbkTarget.Sheets("Summary")
If wksTarget Is Nothing Then
MsgBox "Could not locate sheet"
Else
lRow_2006 = Sheets("Summary").Range("A" & _
Sheets("Summary").Rows.count).End(xlUp).Row
End If
End If

Dave Peterson

workbooks.open - another option
 
You mean to retrieve values from cells on a worksheet?

You can use helper cells in a worksheet and build formulas to do the work

or

You could retrieve values from a closed workbook using a routine from John
Walkenbach:
http://j-walk.com/ss/excel/eee/eee009.txt
Look for either: GetDataFromClosedFile or GetValue.

Mona wrote:

I will be accessing several workbooks (test.xls, test1.xls, ...).

What is the syntax to "reference" workbook without having to open it?

thanks
-Mona

Set wbkTarget = Workbooks.open(Filename:="c:\ test.xls")
If wbkTarget Is Nothing Then
MsgBox "Can not open file"
Else
Set wksTarget = wbkTarget.Sheets("Summary")
If wksTarget Is Nothing Then
MsgBox "Could not locate sheet"
Else
lRow_2006 = Sheets("Summary").Range("A" & _
Sheets("Summary").Rows.count).End(xlUp).Row
End If
End If


--

Dave Peterson

Mona

!
 
I wanted to retrieve data from close file.

Thank you!

"Dave Peterson" wrote:

You mean to retrieve values from cells on a worksheet?

You can use helper cells in a worksheet and build formulas to do the work

or

You could retrieve values from a closed workbook using a routine from John
Walkenbach:
http://j-walk.com/ss/excel/eee/eee009.txt
Look for either: GetDataFromClosedFile or GetValue.

Mona wrote:

I will be accessing several workbooks (test.xls, test1.xls, ...).

What is the syntax to "reference" workbook without having to open it?

thanks
-Mona

Set wbkTarget = Workbooks.open(Filename:="c:\ test.xls")
If wbkTarget Is Nothing Then
MsgBox "Can not open file"
Else
Set wksTarget = wbkTarget.Sheets("Summary")
If wksTarget Is Nothing Then
MsgBox "Could not locate sheet"
Else
lRow_2006 = Sheets("Summary").Range("A" & _
Sheets("Summary").Rows.count).End(xlUp).Row
End If
End If


--

Dave Peterson



All times are GMT +1. The time now is 03:35 PM.

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