Opening another workbook file
Hi J,
Try something like:
'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim sStr As String
Dim sStr2 As String
Set WB = ThisWorkbook
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE
sStr = SH.Range("A1").Value
sStr2 = SH.Range("A2").Value
Set WB = Workbooks.Open(Filename:=sStr & sStr2)
End Sub
'<<=============
---
Regards,
Norman
"J. Barrington at" <"jbarrington comcast: net" wrote in message
. ..
The line below seems to open the file ”book1.xls”:
Workbooks.Open “C:\famous\book1.xls”
I will need to easily change the path location of a workbook, or change
the workbook name without going back into the routine to do it, nor having
else go to the routine and change it too.
What I want is to have one cell that has the path location
A1 = C:\famous\
another cell that has the filename
A2 = book1.xls
and then have a code that can refer to those two cell locations for
opening another workbook.
I tried to adapt the code from the top with some cell references, but
without success. How can this be done?
|