Pages

Saturday, March 24, 2012

VBA Speed Tips

Turning off screen updating

Application.ScreenUpdating = False

Application.ScreenUpdating = True

 

Sub fillrange()

    Dim r As Long, c As Integer

    Dim number As Long

    number = 0

    Application.ScreenUpdating = False

    For r = 1 To 50

        For c = 1 To 50

            number = number + 1

            Cells(r, c).Value = number

        Next

    Next

    Application.ScreenUpdating = True

End Sub

Turning off automatic calculation

Application.Calculation = xlCalculationManual

Application.Calculation = xlCalculationAutomatic

Display Alerts

Application.DisplayAlerts = False

 

No comments:

Post a Comment