Hi All,
I have the following simple sample workbook as attached.
It has just one sheet and a bunch of formulas from B1:I1.
I want to just write a quick macro to value paste this row 1000 below.
I have tried 3 simple methods as follows:
[VBA]Option Explicit
Sub test()
Dim start_time As Double
Dim i As Long
start_time = Timer
Application.ScreenUpdating = False
For i = 1 To 1000
With Range("B1:I1")
.Offset(i, 0).Value = .Value
End With
Next i
Call MsgBox("Macro took " & (Timer - start_time) & " seconds to run.", vbExclamation Or vbSystemModal, "Time taken for Macro")
Application.ScreenUpdating = True
End Sub
Sub test2()
Dim start_time As Double
Dim i As Long
start_time = Timer
Application.ScreenUpdating = False
For i = 1 To 1000
With Range("B1:I1")
.Copy .Offset(i, 0)
End With
Next i
Call MsgBox("Macro took " & (Timer - start_time) & " seconds to run.", vbExclamation Or vbSystemModal, "Time taken for Macro")
Application.ScreenUpdating = True
End Sub
Sub test3()
Dim start_time As Double
Dim i As Long
start_time = Timer
Application.ScreenUpdating = False
For i = 1 To 1000
Range("B1:I1").Offset(i, 0) = Application.Evaluate(Range("B1:I1").Value)
Next i
Call MsgBox("Macro took " & (Timer - start_time) & " seconds to run.", vbExclamation Or vbSystemModal, "Time taken for Macro")
Application.ScreenUpdating = True
End Sub[/VBA]
Sub test3 currently does not work. Here I am trying to evaluate the range formulas as values before value-pasting down 1000 times.
I know this example seems trivial, but it is part of a larger problem of the same process.
If anyone could advise on how to correct method 3 that would be great.
regards,