Hi.
I am very frustrated with this. i have a small workbook of 992KB with some amount of macro, and some formulas.
Its so slow when running loops, and it only loops 400 columns.
so I have tried running this code in the workbook on a blank sheet. and it is not able to finish, i must force close excel.
But if i run the same looptest in a new workbook, it runs at 6 seconds.
I am very frustrated with this. i have a small workbook of 992KB with some amount of macro, and some formulas.
Its so slow when running loops, and it only loops 400 columns.
so I have tried running this code in the workbook on a blank sheet. and it is not able to finish, i must force close excel.
VBA Code:
Sub looptest()
Dim rng As Range
Dim cCell As Range
Dim i As Long
Dim xlCalc As XlCalculation
With Application
.ScreenUpdating = False
xlCalc = .Calculation
.Calculation = xlCalculationManual
.EnableEvents = False
.DisplayAlerts = False
End With
Set rng = Range("A1:A400000")
i = 1
Range("C1") = Now()
For Each cCell In rng
cCell.Value = i
i = i + 1
Next cCell
Range("C2") = Now()
With Application
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
.Calculation = xlCalc
End With
End Sub
But if i run the same looptest in a new workbook, it runs at 6 seconds.