Hi All,

Hoping you can help. I have a piece of code which I found on a forum years ago and have been using successfully in a number of projects. The code basically gets you to select a workbook, opens it, and copies the worksheets to the matching sheets in the original workbook. Eg, opens a workbook, copies contents of worksheet 'ABCD' from the new workbook to worksheet 'ABCD' in the original workbook. It works fine when opening workbooks in 2003 format. When I run the code and open a 2007 workbook, I get an Excel error with a big red cross saying:

* Excel cannot complete this task with available resources. Choose less data or close other applications.

Here is the code:

   
 'Select Baseline Items file and copy to main workbook
    Dim intNumber As Integer
    Dim intCount As Integer
    Dim wkbBook As Workbook
    Dim varFile As Variant
    Dim strSheet(1) As String
    strSheet(0) = "Baseline Items"
    'strSheet(1) = "Summary Data"
        On Error GoTo Fin
    varFile = Application.GetOpenFilename("All files,*.*", 1, "Select", , True)
    If Not IsArray(varFile) Then Exit Sub
    Application.ScreenUpdating = False
    For intCount = 1 To UBound(varFile)
        Set wkbBook = Workbooks.Open(varFile(intCount))
        For intNumber = 0 To 1
            If WorkSheetExists(wkbBook.Name, strSheet(intNumber)) Then
                wkbBook.Sheets(strSheet(intNumber)).Range(wkbBook.Sheets(strSheet(intNumber)).Cells(5, 1), wkbBook.Sheets(strSheet(intNumber)).Cells.SpecialCells(xlCellTypeLastCell)).Copy _
                Destination:=ThisWorkbook.Sheets(wkbBook.Sheets(strSheet(intNumber)).Name).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
                        
            End If
        Next intNumber
        wkbBook.Close False
    Next intCount
I'm gathering it has something to do with the greater number of lines in the newer version so I may be trying to copy hundreds of thousands of lines instead of tens of thousands as I did in 2003.

I'd appreciate any assistance in figuring out why this code no longer works with 2007/2010 Excel.

Many thanks

Trav