View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Copy data from one workbook to another of same name

Expand the lists to include all of your source and corresponding destination
files.

Sub CopyFiles()
Dim PathSrc as String, PathDest as String
Dim srcList as Variant, destList as Variant
Dim i as Long
Dim bkSrc as Workbook, bkDest as Workbook

PathSrc = "C:\MyFiles\"
PathDest = "C:\YourFiles\"
srcList = Array("AE1234.xls", _
"AB3567.xls", _
"RN2134.xls", _
"ZZ9999.xls")

destList = Array("bb1111.xls", _
"cc2222.xls", _
"dd3333.xls", _
"zz1111.xls")

for i = lbound(srcList) to ubound(srcList)
set bksrc = workbooks.Open(PathSrc & srcList(i))
set bkdest = workbooks.Open(PathDest & destlist(i))
bksrc.worksheets(1).Rows(1).Resize(50).copy _
Destination:=bkDest
bksrc.close SaveChanges:=False
bkDest.close SaveChanges:=True
Next

End Sub


If you had come sequence to our names and some corresondence between source
and destination filenames, this could be simpler.

--
Regards,
Tom Ogilvy


"KENNY" wrote in message
...
What if I know precisely the name of the destination file,
as well as its location (Lookup?)?


-----Original Message-----
This can definitely be done in a macro if you are willing

to start the
macro and then find the destination file in an open

prompt...the macro
would then open that file...put in the 50 rows (how many
columns?)...and then close and save the file.

.