more efficient VBA?
Hi Mark
Don't select and activate stuff, it's slow and unnecessary.
Also, if you have formulae there, they will recalculate on every cell entry,
it takes time. Turn calculation temporarily off while writing things to
multiple cells.
Try this, it is be pretty fast:
Sub test()
Dim R As Long
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
For R = 2 To Cells(Rows.Count, 12).End(xlUp).Row
Cells(R, 14).FormulaR1C1 = _
"=CONCATENATE(C[-7],C[-6])"
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
HTH. Best wishes Harald
"markx" skrev i melding
...
Hello,
I have the following macro:
------------------------
Sub Test()
Range("N2").Select
Do
ActiveCell.FormulaR1C1 = "=CONCATENATE(C[-7],C[-6])"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -2))
End Sub
------------------------
It works fine, the only problem is that it takes time (20 seconds to treat
1000 rows).
Are you aware of any more efficient way of writing this type of code?
Thanks for any hints!
Regards,
Mark
|