Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
set up a command button to print multiple workbook casper Excel Discussion (Misc queries) 2 August 28th 09 12:00 AM
copy the command button and macro for multiple rows bigproblem Excel Discussion (Misc queries) 6 April 5th 09 09:46 PM
Command Button to make multiple duplicate worksheets Roxy Excel Worksheet Functions 0 February 13th 08 06:58 PM
Create refresh button in worksheet to refresh Pivot Table Data Ron Excel Worksheet Functions 1 October 13th 07 01:20 AM
I cannot refresh all of the queries in my spreadsheet Peter Excel Discussion (Misc queries) 0 July 25th 06 04:23 PM


All times are GMT +1. The time now is 06:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"