G
Guest
Hi all,
I have a piece of code which simply copies a large range of data (500 rows)
to a different worksheet within the same workbook. The copied range contains
many formulas (single cell and array formulas), some of which reference
different worksheets.
My problem is: I have noticed that each time my code is run, this copy/paste
operation takes a little bit longer than before. I even wrote an infinite
loop to see the effect (over time) of repeatedly performing the same
copy/paste operation:
Public Sub myTest()
Dim myTimer As Long
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Application.ScreenUpdating = False
While True
myTimer = Timer
Range("EventLog!A1:IV500").Copy Range("TempLog!A1:IV500")
Debug.Print Timer - myTimer
Wend
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Each time the loop iterates, it takes just a little bit longer. I have
noticed that when I paste the data as values only (no formulas), the problem
does not occur.
I should also mention that this problem also happens when I manually (not
via code) copy the source range and paste to the destination range.
Could this be some sort of problem with dependency trees or something like
that?
Please help!!!
Many thanks in advance - David
I have a piece of code which simply copies a large range of data (500 rows)
to a different worksheet within the same workbook. The copied range contains
many formulas (single cell and array formulas), some of which reference
different worksheets.
My problem is: I have noticed that each time my code is run, this copy/paste
operation takes a little bit longer than before. I even wrote an infinite
loop to see the effect (over time) of repeatedly performing the same
copy/paste operation:
Public Sub myTest()
Dim myTimer As Long
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Application.ScreenUpdating = False
While True
myTimer = Timer
Range("EventLog!A1:IV500").Copy Range("TempLog!A1:IV500")
Debug.Print Timer - myTimer
Wend
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Each time the loop iterates, it takes just a little bit longer. I have
noticed that when I paste the data as values only (no formulas), the problem
does not occur.
I should also mention that this problem also happens when I manually (not
via code) copy the source range and paste to the destination range.
Could this be some sort of problem with dependency trees or something like
that?
Please help!!!
Many thanks in advance - David