I have a table with the Columns: Date, Col1, Col2, Col3.
I want to copy all the rows with the same date into a new workbook. The date is in order. I have a code written that works. However, it takes forever to run, because it is looping through each row. I have A LOT of rows.
Is there no way to just select and copy a chunk and then paste it all just once? I think it takes long because it is pasting each individual row separately.
Thanks.
Here is my code:
Sub CopyToWorkbook()
Dim NewBook As Workbook
Dim OldBook As Workbook
Dim Import As Worksheet
Dim Raw As Worksheet
Dim t As Long
Set OldBook = Workbooks("OldBook.xlsm")
Set Import = OldBook.Worksheets("import.xlsm")
Set NewBook = Workbooks.Add
NewBook.Sheets.Add.Name = "Raw"
Set Raw = NewBook.Worksheets("raw")
Do While Import.Cells(t, 2) = "8/19/2014"
Import.Cells(t, 1).EntireRow.Copy Destination:=Raw.Cells(t, 1)
t = t + 1
Loop
End Sub
Bookmarks