View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Philip Philip is offline
external usenet poster
 
Posts: 156
Default 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