This is my first post. I found the below code on this site that allows me to merge multiple workbooks in one workbook placing each workbook on a separate sheets. This works perfectly when run at home on my pc which is running excel 2007, however at work when I run the same code (in Excel 2007, just modifying the MyPath to appropriate destination) I get the following "Excel cannot insert sheets into the destination workbook because it contains fewer rows and columns than the source workbook. To move or copy the data to the destination workbook, you can select the data then use copy and paste commands to insert it into the sheets of another workbook." Any suggestions as to what I might be doing wrong?
Code:
Sub Merge2MultiSheets()
Dim wbDst As Workbook
Dim wbSrc As Workbook
Dim wsSrc As Worksheet
Dim MyPath As String
Dim strFilename As String
On Error GoTo Errorcatch
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.ScreenUpdating = False
MyPath = "D:\Dept E\Div E1\1-Aug2011"
Set wbDst = Workbooks.Add(xlWBATWorksheet)
strFilename = Dir(MyPath & "\*.xls", vbNormal)
If Len(strFilename) = 0 Then Exit Sub
Do Until strFilename = ""
Set wbSrc = Workbooks.Open(Filename:=MyPath & "\" & strFilename)
Set wsSrc = wbSrc.Worksheets(1)
wsSrc.Copy After:=wbDst.Worksheets(wbDst.Worksheets.Count)
wbSrc.Close False
strFilename = Dir()
Loop
wbDst.Worksheets(1).Delete
Application.DisplayAlerts = True
Application.EnableEvents = True
Application.ScreenUpdating = True
Errorcatch:
MsgBox Err.Description
End Sub