I have a workbook with a lot of formulas and several queries and I would like to speed up the speed by having the calculations turn off at the beginning of this macro and having them turn back on when all the queries have finished refreshing.
Sub updateorders()
'
' updateorders Macro
'
'
Sheets("PLANNING").Select
Range("S2:T5000").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("W2:W5000").Select
Application.CutCopyMode = False
Selection.ClearContents
ActiveWorkbook.Connections("OPEN ORDERS").Refresh
ActiveWorkbook.Connections("INVENTORY").Refresh
ActiveWorkbook.Connections("Assemblies").Refresh
ActiveWorkbook.Connections("Open PO's").Refresh
Sheets("wip").Select
Columns("I:I").Select
Selection.TextToColumns Destination:=Range("I1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 2), TrailingMinusNumbers:=True
Sheets("PLANNING").Select
Range("AI1").Select
Selection.ClearContents
Range("AI1").Select
ActiveCell.FormulaR1C1 = "3"
Range("AI2").Select
End Sub
I created a class module with this code
Public WithEvents qt As QueryTable
Private Sub qt_BeforeRefresh(Cancel As Boolean)
Application.Calculation = xlManual
End Sub
Private Sub qt_AfterRefresh(Cancel As Boolean)
Application.Calculation = xlAutomatic
End Sub
but I must be missing something because it's not working. I am using excel 2010.
thanks
Bookmarks