![]() |
How can I open an Excel workbook using a cell containing the path and filename
I have a file folder with sequentially numbered filenames (1000.xls,
1001.xls...) I am trying to automate the opening and data extraction in the file by letting the user type in the filename number eg 1000 in a cell. In 2 cells I would put the file path in one cell and .xls in another. Finally I would concatenate all 3 cells to give me the path and filename of the file to open. I would put a button on the working sheet that would initiate the program that would open the file using the path/filename in the third cell where the path/filename/path was assembled. I figured out how to do the data extraction but I just can't figure out for the life of me how to get Workbook.Open to work using a cell address for the filename. There might be a much easier way to do this than what I came up with but I am just a newbie messing with this. I hope someone can help. Thanks, Denis |
How can I open an Excel workbook using a cell containing the path and filename
Dim oWB as excel.workbook
set oWB=workbooks.open(sheet1.range("A1").value & _ sheet1.range("A2").value & ".xls") Where A1=path and A2=filename. Tim "Denis" wrote in message ... I have a file folder with sequentially numbered filenames (1000.xls, 1001.xls...) I am trying to automate the opening and data extraction in the file by letting the user type in the filename number eg 1000 in a cell. In 2 cells I would put the file path in one cell and .xls in another. Finally I would concatenate all 3 cells to give me the path and filename of the file to open. I would put a button on the working sheet that would initiate the program that would open the file using the path/filename in the third cell where the path/filename/path was assembled. I figured out how to do the data extraction but I just can't figure out for the life of me how to get Workbook.Open to work using a cell address for the filename. There might be a much easier way to do this than what I came up with but I am just a newbie messing with this. I hope someone can help. Thanks, Denis |
How can I open an Excel workbook using a cell containing the path and filename
Thanks Tim. Works like a charm. Such a short code too. Amazing.
Denis "Tim Williams" <timjwilliams at gmail dot com wrote in : Dim oWB as excel.workbook set oWB=workbooks.open(sheet1.range("A1").value & _ sheet1.range("A2").value & ".xls") Where A1=path and A2=filename. Tim Denis |
All times are GMT +1. The time now is 12:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com