Recently, I encountered a problem which seems to be quite simple to resolve, but I'm new to VBA and due to this I need any advice. I'm trying to write a macro in VBA which copies a very large sheet (around 140k of lines).
I tried different approaches based on the following topics:
- Fastest Method to Copy Large Number of Values in Excel VBA
- Large File Size Copy Ranges with VBA Very large excel file - how to copy data between sheets?
My current solution is:
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Dim wb As Workbook
Set wb = ActiveWorkbook
With Workbooks.Open(FileName, ReadOnly:=True)
.Sheets(1).Visible = -1
.Sheets(1).Copy before:=wb.Sheets(1)
wb.Sheets(1).Name = "Name"
.Close False
End With
When I'm running this macros - Excel is not responding and program is not opening the file. My question is, is it any possibility to copy a large sheet using standard VBA methods? The code sample works absolutely fine with smaller files.