excel - Variable Directory in Loop -
i'm trying make macro allows user select file (excel file) used copy down information active workbook selected file. don't know how include file's variable directory code. got idea?
sub ref() dim path string path = application.getopenfilename dim r integer r = 1 r = 1 1000 if not isempty(range(path(cells(r, 1)))) cells(r, 1) = range(path(cells(r, 1))) end if next end sub
it seems have list of excel workbooks path(s) in column a. going have open workbook if want retrieve information cell(s) in workbook.
this generic framework should started on sub loops through values in active workbook's active worksheet's column a, opens each file listed , transfers value a1 original workbook's column b.
sub ref() dim wb0 workbook, wb1 workbook dim r long, lr long set wb0 = activeworkbook wb0.sheets("sheet1") lr = .cells(rows.count, 1).end(xlup).row r = 1 lr if not isempty(.cells(r, 1)) set wb1 = workbooks.open(.cells(r, 1).value2) .cells(r, 2) = wb1.sheets("sheet1").cells(1, 1).value wb1.close false end if next r end end sub you have expand on own individual situation believe should see process loop through workbooks listed in column a.
Comments
Post a Comment