Open a workbook with a name that was recorded in a cell

G

Guest

I try to open a series of Workbooks from a list created in a Sheet, for ex.:
700.xls
701.xls
702.xls
703.xls
704.xls


ActiveCell.Select
Application.CutCopyMode = False
Selection.Copy
ChDir "E:\Servim\Livrari dupa inventar"
Workbooks.Open Filename:="E:\Servim\Livrari dupa inventar\7011.xls"
End Sub

and I don't want to mention “700. xlsâ€, but to write “the content of cell A1â€
Thank of support.
 
T

Tim Williams

'*************************************************
Const DIR_PATH as string="E:\Servim\Livrari dupa inventar\"
dim fName as string

fName=thisworkbook.sheets("Sheet1").range("A1").value
Workbooks.Open Filename:=DIR_PATH & fname
'*************************************************

You don't need the ChDir if you specifiy the full path to the workbook.
 
G

Guest

"Tim Williams" a scris:
'*************************************************
Const DIR_PATH as string="E:\Servim\Livrari dupa inventar\"
dim fName as string

fName=thisworkbook.sheets("Sheet1").range("A1").value
Workbooks.Open Filename:=DIR_PATH & fname
'*************************************************

You don't need the ChDir if you specifiy the full path to the workbook.

Thanks millions
Emil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top