+ Reply to Thread
Results 1 to 8 of 8

Run Code after Automatic Refresh

  1. #1
    Registered User
    Join Date
    07-22-2009
    Location
    Alabama
    MS-Off Ver
    Excel 2003
    Posts
    9

    Run Code after Automatic Refresh

    I currently have an Excel Workbook that pulls data from an Access Database every 10 minutes (using Data -> Import External Data). What I am trying to do is run some code, that I have written, automatically after every refresh occurs. Currently I have not been able to find a way to do this, can anyone help?

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Run Code after Automatic Refresh

    use event code "change" in worksheet event code

    right click sheet tab and click view code and in the sheet code window
    in the left arrow choose "worksheet"
    in the right arrow choose "change"
    from the drop down lists.

    you write the code there.

    this means whenever the target ( a particular cell in the sheet changes due to refresh) changes value due to refresh, the code will run. If a number of cells change due to refresh then make the last cell which changes as the target.

    you have to some experiments with a dummy file.

  3. #3
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388

    Re: Run Code after Automatic Refresh

    Quote Originally Posted by JVollmer View Post
    What I am trying to do is run some code, that I have written, automatically after every refresh occurs.
    See Visual Basic Help topic QueryTable Object Events

  4. #4
    Registered User
    Join Date
    07-22-2009
    Location
    Alabama
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Run Code after Automatic Refresh

    Quote Originally Posted by venkat1926 View Post
    use event code "change" in worksheet event code

    right click sheet tab and click view code and in the sheet code window
    in the left arrow choose "worksheet"
    in the right arrow choose "change"
    from the drop down lists.

    you write the code there.

    this means whenever the target ( a particular cell in the sheet changes due to refresh) changes value due to refresh, the code will run. If a number of cells change due to refresh then make the last cell which changes as the target.

    you have to some experiments with a dummy file.
    Using a Change Event just causes an almost endless loop since part of the code that is running is formatting that data that was just brought in. This was the first thing I tried.

  5. #5
    Registered User
    Join Date
    07-22-2009
    Location
    Alabama
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Run Code after Automatic Refresh

    Quote Originally Posted by T-J View Post
    See Visual Basic Help topic QueryTable Object Events
    QueryTable Object Events do not seem to be exisitant in Excel 2003, only 2007. Any other ideas?

  6. #6
    Forum Contributor
    Join Date
    06-12-2009
    Location
    Banglore
    MS-Off Ver
    Excel 2007
    Posts
    126

    Re: Run Code after Automatic Refresh

    This works fine guys...
    Shan

  7. #7
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388

    Re: Run Code after Automatic Refresh

    Quote Originally Posted by JVollmer View Post
    QueryTable Object Events do not seem to be exisitant in Excel 2003, only 2007. Any other ideas?
    Incorrect, they are available in 2003. Again, read the help topic.

  8. #8
    Registered User
    Join Date
    07-22-2009
    Location
    Alabama
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Run Code after Automatic Refresh

    Quote Originally Posted by T-J View Post
    Incorrect, they are available in 2003. Again, read the help topic.
    I apologize, you are correct. I finally got it to work using the QueryTable Events. Thanks for your help T-J

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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