How can I open an Excel workbook using a cell containing the path and filename

D

Denis

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
 
T

Tim Williams

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
 

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