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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,553
Messages
6,114,279
Members
448,562
Latest member
Flashbond

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
Back
Top