Command button to refresh data

G

Greg Snidow

Greetings all. I am not good at excel programming, but I figured out how to
add a command button and to record a new macro to assign to its click event.
I have a workbook with two worksheets, each having a separate SQL Server 2000
query as the datasource. During the record new macro step I highlighted the
first cell in the data range on the first worksheet, then hit Data>Refresh to
requery the data. Then I highlighted the first cell in the data range of
sheet 2 and did the same thing. The button works, but it shows all the steps
I included in the record step. Is there a way to refresh every sheet in the
workbook at once, with one click of the button, regardless of the source
query? The below is what was generated by the macro recorder.

Sub Button11_Click()
'
' Button11_Click Macro
' Macro recorded 10/8/2007 by greg snidow
'
' Keyboard Shortcut: Ctrl+d
'
Range("A8").Select
ActiveWindow.SmallScroll Down:=-9
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("EWO_VIEW").Select
Range("A4").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("VA VIEW").Select
End Sub
 
G

Greg Snidow

It figures, two minutes after I posted I found my answer in a Post by KLZA on
8/2/2007.
Activeworksheet.refreshall worked like a charm. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top