#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
mg_sv_r
 
Posts: n/a
Default merge workbooks

I have 40 Workbooks, that I wish to merge into one.

Rows 1 to 4 on the workbooks are identical, containing column headers and
data entry instructions so all I want to merge is everything that appears on
or after row 5.

I have tried, unsuccessfuly, to adapt the script below, found on here but
this seems to hit problems due to the fact all my workbooks have Userforms on
them and I'm not entirely sure how the 'range' is specified

-------------
Sub merge()
Set active = ActiveSheet

With Application.FileSearch
.NewSearch
.LookIn = "J:\Revenue Accounts\FRAUD DATA\New Folder\"
If .LookIn = "" Then Exit Sub
.SearchSubFolders = True
.FileName = "*.xls"
.Execute

Rownumber = 2

Application.ScreenUpdating = False
Application.DisplayAlerts = False

For i = 1 To .FoundFiles.Count
'Open each workbook
Set wb = Workbooks.Open(FileName:=.FoundFiles(i))
Set myrange = Range("a2:b" & Range("a5").CurrentRegion.Rows.Count)
myrange.Copy active.Cells(Rownumber, 1)
Rownumber = Rownumber + myrange.Rows.Count
ActiveWorkbook.Close

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

------------
Can anybody give any help and/or suggestions on how to do this?

Regards
John
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron de Bruin
 
Posts: n/a
Default merge workbooks

Hi

See http://www.rondebruin.nl/copy3.htm

Try this example
http://www.rondebruin.nl/copy3.htm#header


--
Regards Ron De Bruin
http://www.rondebruin.nl



"mg_sv_r" wrote in message ...
I have 40 Workbooks, that I wish to merge into one.

Rows 1 to 4 on the workbooks are identical, containing column headers and
data entry instructions so all I want to merge is everything that appears on
or after row 5.

I have tried, unsuccessfuly, to adapt the script below, found on here but
this seems to hit problems due to the fact all my workbooks have Userforms on
them and I'm not entirely sure how the 'range' is specified

-------------
Sub merge()
Set active = ActiveSheet

With Application.FileSearch
.NewSearch
.LookIn = "J:\Revenue Accounts\FRAUD DATA\New Folder\"
If .LookIn = "" Then Exit Sub
.SearchSubFolders = True
.FileName = "*.xls"
.Execute

Rownumber = 2

Application.ScreenUpdating = False
Application.DisplayAlerts = False

For i = 1 To .FoundFiles.Count
'Open each workbook
Set wb = Workbooks.Open(FileName:=.FoundFiles(i))
Set myrange = Range("a2:b" & Range("a5").CurrentRegion.Rows.Count)
myrange.Copy active.Cells(Rownumber, 1)
Rownumber = Rownumber + myrange.Rows.Count
ActiveWorkbook.Close

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

------------
Can anybody give any help and/or suggestions on how to do this?

Regards
John



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
excel show merge workbooks button micky Excel Discussion (Misc queries) 2 April 26th 06 10:04 PM
How do I Compare and Merge Workbooks in Excel? Hannah Excel Discussion (Misc queries) 0 January 18th 06 04:28 PM
Excel: how to merge data from 2 workbooks with 1 col. in common? Cesare Excel Discussion (Misc queries) 2 June 24th 05 11:14 PM
Tools/Compare and Merge Workbooks - Excel 2003 Pro Laura Excel Worksheet Functions 1 January 3rd 05 05:45 PM
how can i merge 2 workbooks using a formula? John F Excel Worksheet Functions 6 November 23rd 04 04:45 PM


All times are GMT +1. The time now is 03:49 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"