vba - Excel macro to open a folder of excel workbooks and copy 1 cell -
i have folder of .xlsx files, each identical in layout.
i need write macro in excel open each file in turn (100+ files) data (a name) single cell, , drop in new excel worksheet, move on next , insert below last 1 etc.
giving me list of names data not file names)
here (pretty much) you're trying do. next time little bit of googling before ask! :)
http://www.excel-easy.com/vba/examples/files-in-a-directory.html
rough code unsure if work: here basic idea of need modify in example sent you. if @ example again, need , some. since weren't interested in worksheets, don't have loop through worksheets in workbook. can open up, read cell of interest, , close it. while loop every excel file in directory. again! please modify example accordingly before use it.
dim directory string, filename string, sheet worksheet, integer, j integer application.screenupdating = false directory = "c:\test\" filename = dir(directory & "*.xl??") while filename <> "" = + 1 workbooks.open (directory & filename) workbooks("files-in-a-directory.xls").worksheets(1).cells(i, 1).value = workbooks(filename).worksheets(1).cells(x, y) <-- whatever cell of interest workbooks(filename).close filename = dir() loop application.screenupdating = true
Comments
Post a Comment