Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default merge multiple files from text list of file pairs


I am looking for some examples to get me going on a project to read a
text file which contains in column a and column b file name pairs. I
want to open the two files referred to in a1 and b1, copy a range from
file b1 into a set location in file a1, save a1, close both, then loop
to files a2 and b2 etc. Have about 1000 pairs to loop through so
investing time into getting this to work in an automated fashion would
be great.

Anyone have some examples or ideas regarding the toughest part which to
me is getting the file name pairs, copying code from b to a?

Thanks.

Rob


--
rroach
------------------------------------------------------------------------
rroach's Profile: http://www.excelforum.com/member.php...o&userid=21093
View this thread: http://www.excelforum.com/showthread...hreadid=378844

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default merge multiple files from text list of file pairs

Hi Rob,

Try something like:

Sub Tester()

Dim wbList As Workbook
Dim wbSrc As Workbook
Dim wbDest As Workbook
Dim rcell As Range
Const copyAddress As String = "F1:F4"
Const destAddress As String = "A1"

With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With

Set wbList = Workbooks.Open("YourFilelistBook")

For Each rcell In wbList.Sheets(1).Range("A1"). _
CurrentRegion.Columns(1).Cells
Set wbDest = Workbooks.Open(rcell.Value)
Set wbSrc = Workbooks.Open(rcell(1, 2).Value)
wbSrc.Sheets(1).Range(copyAddress).Copy _
Destination:=wbDest.Sheets(1).Range(destAddress)
wbSrc.Close savechanges:=False
wbDest.Close savechanges:=True
Set wbSrc = Nothing
Set wbDest = Nothing
Next

wbList.Close savechanges:=False

With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With

End Sub

---
Regards,
Norman



"rroach" wrote in
message ...

I am looking for some examples to get me going on a project to read a
text file which contains in column a and column b file name pairs. I
want to open the two files referred to in a1 and b1, copy a range from
file b1 into a set location in file a1, save a1, close both, then loop
to files a2 and b2 etc. Have about 1000 pairs to loop through so
investing time into getting this to work in an automated fashion would
be great.

Anyone have some examples or ideas regarding the toughest part which to
me is getting the file name pairs, copying code from b to a?

Thanks.

Rob


--
rroach
------------------------------------------------------------------------
rroach's Profile:
http://www.excelforum.com/member.php...o&userid=21093
View this thread: http://www.excelforum.com/showthread...hreadid=378844



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default merge multiple files from text list of file pairs


Norman,

Wow! Nice solution. Thanks so much!

I'll let you know how it goes, but after reading and glimpsing its
simplicity I think it will work just fine.

Rob


--
rroach
------------------------------------------------------------------------
rroach's Profile: http://www.excelforum.com/member.php...o&userid=21093
View this thread: http://www.excelforum.com/showthread...hreadid=378844

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merge Multiple Single Worksheet Excel Files into one file in separ dbguy11 Excel Discussion (Misc queries) 6 April 3rd 23 04:20 PM
how do I merge multiple csv files in one Excel file? Nedulous Excel Worksheet Functions 4 May 17th 09 04:07 PM
How do I merge multiple xls files into one file? Steve Excel Discussion (Misc queries) 5 April 26th 07 08:28 PM
How do I merge multiple xls files into one file? Gianni Excel Discussion (Misc queries) 3 June 14th 05 02:09 PM
Merge file pairs rroach Excel Discussion (Misc queries) 1 June 14th 05 03:43 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"