Pages

Tuesday, August 11, 2009

VBA Macro - Speed up

Excel to Tally
If you have Excel VBA macro code (using with UDIMagic) that runs slow, the chances are it's caused by Excel having to recalculate at each line of code.

The code below shown how we can switch calculation into manual, run some code, then put it back how it was.

Sub GoToManual()

Dim xlCalc As XlCalculation

xlCalc = Application.Calculation
Application.Calculation = xlCalculationManual
On Error GoTo CalcBack

'YOUR CODE

Application.Calculation = xlCalc
Exit Sub

CalcBack:

Application.Calculation = xlCalc
End Sub

No comments: