Refresh

dantb

Active Member
Joined
Mar 20, 2002
Messages
358
Hi all. What I am trying to do is, refresh a query on a different sheet in the same workbook. The code below will refresh on the same sheet, but is it possible to run a refresh from sheet1, that refreshes sheet2? Thanks Dan


Private Sub Refresh_Click()
Selection.QueryTable.REFRESH BackgroundQuery:=False
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

zzydhf

Board Regular
Joined
Apr 10, 2002
Messages
236
you should just have to select the sheet, select a cell inside the query range, run the query and reselect sheet1
e.g.
Sheets("Sheet2").Select
Range("a2").Select
Selection.QueryTable.REFRESH BackgroundQuery:=False
Sheets("Sheet1").Select

you can turn off screenupdating so this won't be seen...

_________________
Oh, you hate your job? Why didn't you say so? There's a support group
for that. It's called EVERYBODY, and they meet at the bar. - Drew Carey
This message was edited by zzydhf on 2002-10-04 21:40
 
L

Legacy 98055

Guest
Hi Dan.
I'm not altogether 100% on this, but I believe you can use the name of the query to refresh. See Insert>Name>Define for a list of your queries. You will need to know the names or atleast the range in which you originally imported the data.
Ex.
<pre>
Sub MultiRefresh()
Sheet1.Range("QueryOnSheetOne").QueryTable.Refresh BackgroundQuery:=False
Sheet2.Range("QueryOnSheetTwo").QueryTable.Refresh BackgroundQuery:=False
End Sub

</pre>
Tom
 

dantb

Active Member
Joined
Mar 20, 2002
Messages
358
Thx zz & Ts, will try both, mabby I can get it working. Thanks again. Dan
 

Forum statistics

Threads
1,144,220
Messages
5,723,091
Members
422,477
Latest member
pete101

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top