ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Mass copy of excel docs (https://www.excelbanter.com/excel-programming/351156-mass-copy-excel-docs.html)

[email protected]

Mass copy of excel docs
 
I have {30} several documents -- Excel that I want to copy some cells
to a new template. I want to use a macro for this. Any suggestions??


Tom Ogilvy

Mass copy of excel docs
 
How can the several documents be identified. To they all start with a
common root word. Are they the only .xls files in a directory.

Copy to a new template -

do you want to consolidate all on one page

Dim bk1 as Workbook, bk as Workbook
Dim sName as String, dim rng as Range
set bk1 = Workbooks.Add
sName = Dir("C:\MyDocs\*.xls")
do while sName < ""
set bk = Workbooks.Open("C:\MyDocs\" & sName)
bk.worksheets(1).Range("A1").Resize(5,5).copy
set rng = bk1.Worksheets(1).Cells(rows.count,1).End(xlup)(2)
rng.PasteSpecial xlValues
bk.close SaveChanges:=False
sName = Dir()
Loop

--
Regards,
Tom Ogilvy

wrote in message
oups.com...
I have {30} several documents -- Excel that I want to copy some cells
to a new template. I want to use a macro for this. Any suggestions??





All times are GMT +1. The time now is 07:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com