Skip to content

Instantly share code, notes, and snippets.

@ndthanh
Last active April 28, 2018 13:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ndthanh/fc103355a0fb6ce37a78b3542c5951f6 to your computer and use it in GitHub Desktop.
Sub withoutCalculationSettings()
Dim i As Long, t As Single
t = Timer
With Sheet1
For i = 1 To 1000
.Range(.Range("A" & i), .Range("E" & i)).Formula = _
"=randbetween(1,1000)"
Next
End With
MsgBox "Done " & (Timer - t)
End Sub
Sub withCalculationSettings()
Dim i As Long, t As Single
t = Timer
With Sheet1
Application.Calculation = xlCalculationManual
For i = 1 To 1000
.Range(.Range("A" & i), .Range("E" & i)).Formula = _
"=randbetween(1,1000)"
Next
Application.Calculation = xlCalculationAutomatic
End With
MsgBox "Done " & (Timer - t)
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment