View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 2 Files open - Paste to One

That is the point Chris. You say you are processing 100 files, so it
doesn't open itself. When you open it, set a reference to it and use that
reference.

for example, if you were opening all the files in a single directory

Dim bk as Workbook
Dim sName as String
sName = Dir("C:\Myfolder\*.xls")
do while sName < ""
set bk = Workbooks.Open("C:\MyFolder\" & sName)
Workbooks("Macro1.xls").Worksheets("Sheet5").Range ("1:2").copy
bk.Worksheets(1).Rows(3).Insert Shift:=xldown
loop

Adapt if you are working through a list of names.

--
Regards,
Tom Ogilvy



wrote in message
ps.com...
Hi Tom-

Thanks for the reply. This code errors on the set bk line. It is
giving me a run-time error 1004.

Just to be clear....the file that is being pasted into is already open
at the point this code is run. Not sure what the (sName) code is above
as well...

Thanks,
Chris