Forum Discussion

MichaelJSchulz's avatar
MichaelJSchulz
Copper Contributor
May 27, 2022

Refresh All button, multiple Query Tables, and VBA

I have an Excel workbook containing multiple Query Tables.

To refresh the data in all the Query Tables, I want the User to click the Refresh All button on the Ribbon.

I have a block of VBA code I want to run automatically once all the tables have completed being refreshed.

Over time, the number of Query Tables within the workbook may change, e.g. a new table may get added and/or a table may get removed.

 

How can this be accomplished?

11 Replies

  • alannavarro's avatar
    alannavarro
    Iron Contributor

    Something similar that I did. 


    Right click the query > Properties 

    Checkbox of Enable background refresh is always selected. You need to remove that.

    When you do the refresh all with the vba code, the query is going refresh and wait until it is refreshed to move to the next line of code.

     

    I think that if you are going to have more than 1 table, then you need to look for a code that loops over all the tables in the workbook and do that step of removing the enable background refresh.

     

     

    MichaelJSchulz 

    • MichaelJSchulz's avatar
      MichaelJSchulz
      Copper Contributor

      alannavarro

      The tables are not going to be refreshed with VBA code; the tables are going to be refreshed by the user clicking the Refresh All button.

       

       

      • NikolinoDE's avatar
        NikolinoDE
        Gold Contributor

        MichaelJSchulz 

        Is that what's not working?

        Have you pressed the small file?...or can't you press the button at all?

        However, a file would be appropriate to reproduce this.

    • MichaelJSchulz's avatar
      MichaelJSchulz
      Copper Contributor
      NikolinoDE
      I am not sure I understand how this subroutine would accomplish the goal. How does this make possible the triggering of my block of code after all tables have finished being refreshed?
      • NikolinoDE's avatar
        NikolinoDE
        Gold Contributor

        MichaelJSchulz 

        How to add a custom Ribbon tab using VBA?

        I probably misinterpreted the translation, anyway here's some additional info

        ...if this doesn't help, please ignore my post.

         

        If you allow, would recommend to inform more info about Excel version, operating system, storage medium. A file (without sensitive data) or photos with a more detailed explanation lead to greater success in getting a precise and accurate solution proposal.

         

         

Resources