Hello.
I have a small "template" form (A1:L19) that I need to copy multiple times to a different worksheet for printing.
It takes over half a minute for excel to copy it 20 times.
The "template" contains joined cells, colors, different formattings, row heights, etc.
without SR.Copy Destination:=DR line it takes maybe 5 seconds (still a bit too long for what's it's doing)
Here is a template I'm testing it with:
https://drive.google.com/file/d/1EkIXVrOR05KfLs4myWCHsOHbomWaEB53/view
Is there anything can be done to optimize and speed up this process?
Thank you.
Windows 10 x64 Pro, MS Office Pro 2019
P.S.
I've posted exact same question on another forum, and someone replied that their Excel 2013 finish this routine in half a second...maybe something in Excel 2019 messed up?
I have a small "template" form (A1:L19) that I need to copy multiple times to a different worksheet for printing.
It takes over half a minute for excel to copy it 20 times.
The "template" contains joined cells, colors, different formattings, row heights, etc.
Code:
Sub test()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Dim D As Worksheet
Dim S As Worksheet
Dim SR As Range
Dim DR As Range
Set S = Sheets("Base") 'source worksheet
Set D = Sheets("Print") 'destination worksheet
Set SR = S.Range("A1:L19") 'source range
D.Cells.Delete 'clear destination worksheet
colsCount = SR.Columns.Count
rowsCount = SR.Rows.Count
numCopies = 20 'number of copies
curRow = 1
For num = 1 To numCopies
Set DR = D.Range(D.Cells(curRow, 1), D.Cells(curRow + rowsCount, 1)) 'destination range
SR.Copy Destination:=DR 'copy data
For n = 1 To rowsCount
DR.Rows(n).RowHeight = SR.Rows(n).RowHeight 'copy rows height
Next n
curRow = num * rowsCount + 1
Next num
For n = 1 To colsCount
DR.Columns(n).ColumnWidth = SR.Columns(n).ColumnWidth 'copy columns width
Next n
Application.CutCopyMode = False
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
without SR.Copy Destination:=DR line it takes maybe 5 seconds (still a bit too long for what's it's doing)
Here is a template I'm testing it with:
https://drive.google.com/file/d/1EkIXVrOR05KfLs4myWCHsOHbomWaEB53/view
Is there anything can be done to optimize and speed up this process?
Thank you.
Windows 10 x64 Pro, MS Office Pro 2019
P.S.
I've posted exact same question on another forum, and someone replied that their Excel 2013 finish this routine in half a second...maybe something in Excel 2019 messed up?