+ Reply to Thread
Results 1 to 3 of 3

Turn off calculations before query refresh....turn them back on after

Hybrid View

  1. #1
    Registered User
    Join Date
    03-19-2013
    Location
    new hampshire
    MS-Off Ver
    Excel 2010
    Posts
    37

    Turn off calculations before query refresh....turn them back on after

    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

  2. #2
    Forum Contributor
    Join Date
    11-13-2013
    Location
    United States
    MS-Off Ver
    2010
    Posts
    147

    Re: Turn off calculations before query refresh....turn them back on after

    Have you tried putting

    Application.Calculation = xlManual
    at the beginning .. and putting

    Application.Calculation = xlAutomatic
    before the End Sub of your updateorders macro?
    ----
    Mark threads as Solved
    Star those that help

  3. #3
    Registered User
    Join Date
    03-19-2013
    Location
    new hampshire
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Turn off calculations before query refresh....turn them back on after

    Yes, I tried that but despite the order they are listed in the Queries don't referesh untill the very end. I tried the same thing with a delay involved but still no luck
    Last edited by mk3ll00; 05-30-2014 at 03:32 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How can I turn SendKeys back on?
    By foxguy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-29-2013, 04:26 PM
  2. [SOLVED] Can't turn autocalculate back on.
    By thinlizzy in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 06-27-2012, 05:18 PM
  3. Turn the Ribbon back on
    By Motox in forum Excel General
    Replies: 4
    Last Post: 02-17-2012, 03:16 AM
  4. Auto calc on, then turn off, then runtime error how to turn back on
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2011, 10:37 AM
  5. Turn off MS Query auto refresh?
    By dylanemcgregor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-26-2010, 06:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1