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
Post a Comment