![]() |
Command button to refresh data
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 DataRefresh 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 |
Command button to refresh data
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. "Greg Snidow" wrote: 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 DataRefresh 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 |
All times are GMT +1. The time now is 01:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com