merge workbooks

G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top