PC Review


Reply
Thread Tools Rate Thread

Command button to refresh data

 
 
=?Utf-8?B?R3JlZyBTbmlkb3c=?=
Guest
Posts: n/a
 
      8th Oct 2007
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?R3JlZyBTbmlkb3c=?=
Guest
Posts: n/a
 
      8th Oct 2007
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 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
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create refresh button in worksheet to refresh Pivot Table Data =?Utf-8?B?Um9u?= Microsoft Excel Worksheet Functions 1 13th Oct 2007 01:20 AM
Form and Command button refresh? =?Utf-8?B?YmJubzQ=?= Microsoft Access Macros 2 23rd Sep 2005 03:43 PM
Refresh Data Button Command =?Utf-8?B?Sm9obkx1dGU=?= Microsoft Access Form Coding 2 1st Aug 2005 09:04 PM
Refresh a command button on an unbound form =?Utf-8?B?SG9tZSBTY2hvb2wgTW9t?= Microsoft Access 4 12th May 2005 05:13 PM
with back command how can I get all pages to automatically refresh (without hitting refresh button) =?Utf-8?B?dmluY2VuMTE=?= Windows XP General 1 25th Apr 2004 03:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:48 PM.