The below code works fine when I ask it to add the information from the first two files with approximately 200 rows, however if i add a third it crashes Excel. I need this code to combine upward of 40 files each time it is run by the user.
I had originally written the file to use selects and found a post here saying that it could slow down or cause crash and rewrote it to this current iteration removing all selects from the program.
Public Sub ImportUpdates()
Dim ImportXL As Workbook
Dim OpenFiles() As Variant
Dim i As Long
Dim r As Long
Dim n As Long
Dim Crntwrkbk As String
Dim Crng As Range
Dim Cloc As Long
'Application.ScreenUpdating = False
Crntwrkbk = ThisWorkbook.Name
OpenFiles = Application.GetOpenFilename( _
Title:="Select File(s) To Import", _
MultiSelect:=True)
n = Application.CountA(OpenFiles)
For i = 1 To n
Set ImportXL = Workbooks.Open(OpenFiles(i))
ImportXL.Worksheets("Entries").Activate
r = Cells(Rows.Count, "A").End(xlUp).Row
Set Crng = Range(Cells(2, 1), Cells(r, 2))
Crng.Copy
Windows(Crntwrkbk).Activate
Worksheets("Entries").Activate
Cloc = Workbooks(Crntwrkbk).Worksheets("Entries").Range("A65536").End(xlUp).Offset(1).Row
Worksheets("Entries").Range("A" & Cloc).PasteSpecial _
Paste:=xlPasteValues
Application.CutCopyMode = False
ImportXL.Close True
Next i
'Application.ScreenUpdating = True
'Workbooks(Crntwrkbk).Activate
End Sub
Any assistance appreciated.