![]() |
Refresh Multiple Queries via a Command Button
Hello,
I have at least two queries in my workbook that I would like to auto refresh via a Command Button. Can anyone provide a method to do this? Thank you David Morrison |
Refresh Multiple Queries via a Command Button
If they're QueryTables you can try something like this:
Private Sub CommandButton1_Click() Sheet1.QueryTables(1).Refresh End Sub this assumes that the object name of the worksheet is Sheet1 in the Project Explorer window (in the VB Editor, use CTRL-R to show it!) and the commandbutton is named CommandButton1 then you can extend the code to refresh all the tables together like this: dim qTab as querytable for each qtab in activesheet.querytables qtab.refresh next I hope that helps Philip "Dmorri254" wrote: Hello, I have at least two queries in my workbook that I would like to auto refresh via a Command Button. Can anyone provide a method to do this? Thank you David Morrison |
Refresh Multiple Queries via a Command Button
the concept of autorefresh and with a commandbutton are not really
consistent unless you mean you want to set it to autorefresh by clickking a commandbutton. Assuming you just want to have them refresh when the button is clicked. Private CommandButton1_Click() Worksheets("Sheet3").QueryTables(1).Refresh Backgroundquery:=False Worksheets("Sheet5").QueryTables(1).Refresh Backgroundquery:=False End sub -- Regards, Tom Ogilvy "Dmorri254" wrote in message ... Hello, I have at least two queries in my workbook that I would like to auto refresh via a Command Button. Can anyone provide a method to do this? Thank you David Morrison |
All times are GMT +1. The time now is 11:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com