+ Reply to Thread
Results 1 to 4 of 4

Data table refresh called from VBA not finishing before moving on to next line

  1. #1
    Registered User
    Join Date
    09-05-2013
    Location
    Camarillo, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Data table refresh called from VBA not finishing before moving on to next line

    I've run into this problem many times over the last few years, never with any kind of resolution. VBA seems to have a consistent problem where it won't finish a data table refresh before continuing. Normally, you probably wouldn't notice this is happening, but if you're closing a workbook or re-enabling protection later in the code, you'll have problems. If you're closing, it will warn you that closing the workbook will cancel a pending refresh.

    The latest issue I have is with re-enabling protection after calling for a data table refresh. The refresh doesn't complete before the protection is re-enabled and which triggers a protection error and prevents the refresh from happening. There's a UserInterfaceOnly argument in the VBA Protect method which should get around the problem of having to unprotect and then re-protect entirely. I've confirmed that this works with basic operations like making an entry in a cell, but it does not work when refreshing Data Tables (major oversight?). So it seems like this workaround has failed as well which is infuriating. I've run into this problem (VBA not completing refresh) many times over the last few years, never with any kind of resolution and It seems that once again I have no workaround here. Has anyone else come up with anything for these situations?

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,107

    Re: Data table refresh called from VBA not finishing before moving on to next line

    If you are refreshing a specific query in your code (rather than using RefreshAll) you can specify the BackGroundQuery:=False parameter. You can also manually disable background refreshing in the properties for the query/table.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    09-05-2013
    Location
    Camarillo, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Data table refresh called from VBA not finishing before moving on to next line

    Thanks, that worked!

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,107

    Re: Data table refresh called from VBA not finishing before moving on to next line

    Glad to help.

    Please don't forget to mark the thread solved using the Thread tools link at the top of the page.

+ 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. Replies: 6
    Last Post: 02-23-2024, 02:11 PM
  2. Excel Not Finishing Calculation Before Moving to Next Line of Code
    By DBCox in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-18-2014, 03:33 PM
  3. Cube formulas either don't refresh complete or excel hangs when called from VBA
    By lev_myskin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2011, 03:54 PM
  4. import data from access table to excel pivot table - Enable Auto Refresh
    By okl in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-01-2010, 09:38 AM
  5. Refresh external data by command line?
    By h0ffman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-18-2007, 09:08 AM

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