Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Merge Multiple Single Worksheet Excel Files into one file in separ | Excel Discussion (Misc queries) | |||
how do I merge multiple csv files in one Excel file? | Excel Worksheet Functions | |||
How do I merge multiple xls files into one file? | Excel Discussion (Misc queries) | |||
How do I merge multiple xls files into one file? | Excel Discussion (Misc queries) | |||
Merge file pairs | Excel Discussion (Misc queries) |