+ Reply to Thread
Results 1 to 2 of 2

Data Connections - BeforeRefresh / AfterRefresh

  1. #1
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Question Data Connections - BeforeRefresh / AfterRefresh

    Hi All

    I usually know just enough VBA to be able to figure out what's going on from other examples
    But in this case the more I read the more confused I get!!!

    Can anyone tell me if it's possible to call a macro before and after a data connection is refreshed?

    I have several workbooks that contain client data.
    The data pulls via a SQL connection straight from the DB for our CRM software.

    Each time the data is refreshed I'd like to call:
    1. a macro before hand - to copy the table to another sheet
    2. a macro afterwards to compare the 2 tables

    I can write those macros. It's triggering them I'm having trouble with.

    Even with this example on GitHub, I really don't understand how the VBA is working/being associated with my table.
    I downloaded the example workbook, removed their web connection, added my own SQL connection, but nothing happens when I refresh the data

    https://github.com/mcw0933/StackOver...53/tree/master

    Any help would be appreciated
    All the best
    Vicky

  2. #2
    Registered User
    Join Date
    07-02-2013
    Location
    Cheshire
    MS-Off Ver
    Office Professional 2007
    Posts
    79

    Re: Data Connections - BeforeRefresh / AfterRefresh

    Hi Vicky.

    I have had some problems with refreshing data connections - but there is one application level vba line that I find invaluable: 'Application.CalculateUntilAsyncQueriesDone'. If you set up a macro to do the following:
    1. Take the 'before' copy
    2. Refresh all (or just the one(s) you are interested in)
    3. Insert Application.CalculateUntilAsyncQueriesDone
    4. Do your comparison of before v after.

+ 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. Data from Connections
    By stvbrown2184 in forum Excel - New Users/Basics
    Replies: 12
    Last Post: 07-25-2016, 11:25 AM
  2. Data Connections to Web
    By Larry.LeBlanc@O in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 01-09-2014, 02:34 PM
  3. Data Connections to Web
    By Larry.LeBlanc@O in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 08-29-2013, 08:15 PM
  4. Replies: 2
    Last Post: 05-24-2012, 08:43 AM
  5. Event "BeforeRefresh" for PivotTable
    By spottykix in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-30-2010, 12:31 PM
  6. AfterRefresh
    By JSoto in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-23-2007, 07:10 PM
  7. [SOLVED] I need help with QueryTable Events (AfterRefresh)
    By Dean Hinson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-03-2005, 03:06 PM

Tags for this Thread

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