I have written a macro in Excel VBA that basically copy-pastes 53 rows 1440 times, one under another, in order to populate two columns in a ~70000 row table. The macro works, but it takes about five minutes to run completely. This would be fine if I didn't have to run this on ~1000 other files. I am looking for any way to speed up this process so that it doesn't take 5 days to run.
I tried using the range copy method:
Set range1 = {the table I'm copying}
Set range2 = {the cells I want to paste into}
range1.Copy range2
but it took just as long, if not longer.
Here is my current code:
Windows("as_built_comp.xlsm").Activate
Sheets(siteName).Activate
j = Cells(Rows.Count, 1).End(xlUp).Row
Range("C2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
wb.Activate
Range("I12").Select
For i = 1 To 1440
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=56
ActiveCell.Offset(j - 1, 0).Select
Next i
I'm thinking the solution might have something to do with using sql in VBA, but I have yet to learn that syntax. Either way, any advice is greatly appreciated. Thank you for reading!