+ Reply to Thread
Results 1 to 2 of 2

Refreshing Data Query During VBA Macro

  1. #1
    Registered User
    Join Date
    07-01-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    7

    Question Refreshing Data Query During VBA Macro

    Hi,

    I have run into some trouble when trying to automate some excel work. At the moment, the excel workbook is using a plugin to draw data from a database, I believe through SQL. The plugin is used as a formula shown below, where A, B, C, D, and E are all parameters.
    =DerivixExcelAddin.DerivixFunctions.DxDs(A, B, C, D, E)

    Currently, the macro takes the inputted data, sorts specific portions of it and then pastes it into a separate worksheet. I have 20 specific inputs for parameter A that I need to cycle through and fetch data, with parameter B needing to be changed 6 times for each distinct input of parameter A. This would lead me to 120 times I would have to execute this program, multiple times a day if I were to do it without VBA.

    My problem arises when I go to change one of the parameters, lets say change B to B2, the data doesn't refresh because the macro is running. This prevents me from having the macro loop through the different parameters as the data is not updated. Is there anyway to have the data update as I change the parameters? I have tried pauses and halts with no luck.

    Any help would be appreciated greatly, thank you.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,925

    Re: Refreshing Data Query During VBA Macro

    First, go to Data -> Connections. Select the connection. Click on Properties. On the Usage tab, click off the box that says Enable Background refresh.

    Then in the code, before doing the next query add DoEvents. This should force the code to complete all pending actions before moving on.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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. Refreshing Data Query During VBA Macro
    By goodguygreg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2016, 04:39 PM
  2. Replies: 1
    Last Post: 06-14-2012, 08:46 AM
  3. Problem with macro for refreshing database query
    By 19fortysix in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-18-2009, 03:16 PM
  4. Refreshing Web Query Macro
    By samprince in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2007, 06:53 AM
  5. vba codes for refreshing cell data from web query
    By nhat8121 in forum Excel General
    Replies: 3
    Last Post: 01-06-2007, 09:51 PM
  6. problem refreshing data query on yahoos
    By jcoudrie0734 in forum Excel General
    Replies: 0
    Last Post: 10-03-2005, 08:05 PM
  7. [SOLVED] Query to external data not refreshing
    By R Ormerod in forum Excel General
    Replies: 1
    Last Post: 04-01-2005, 04: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