excel - Open files with values stored in cells -


okay title little ambiguous i'm trying following: have column of file names , want open them using vba. i'm assuming have below i'm missing something. number of files can change can't use definite range.

for each cl in workbookc.worksheets("sheet1").range("a"). if cl.value <> "" then. open (filename="cl.value"). end if. next cl 

the code below should work. note suggest not making sure cell not blank checking if file exists using filesystemobject before attempting opening.

dim sourceworksheet set sourceworksheet = workbookc.worksheets("sheet1")  dim row row = 1 10       'rows containing filenames     if sourceworksheet.cells(row, 1).value <> ""         dim xlwb         set xlwb = workbooks.open(sourceworksheet.cells(row, 1).value)             'do stuff         xlwb.close     end if next 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -