Quick Excel / VB / MSQ Question

Deavan

New Member
Joined
Jul 19, 2006
Messages
6
Hello, I just have a quick question. How would I make a report refresh data that comes from a query using a button?

I've already got the button placed in Excel, and I've got it's VB ready to go, I just need to know the syntax / command to refresh the report.

abcd.png


That "!" Exclamation mark, how do I put that in code to press that?

I know it sounds kind of stupid that I'm making a button ON the spreadsheet in order to replicate the same thing that another button does, but most of the users that are going to see this report won't have that actively on their toolbar.

Code:
Private Sub CommandButton1_Click()
    ActiveSheet.Range("A8").Select
    Selection.QueryTable.Refresh BackgroundQuery:=False
End Sub

is what I have so far :confused:

Can anyone help me out?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Excelenator

Board Regular
Joined
Jul 30, 2006
Messages
154
A neat little trick for things like this is to record a macro doing exactly what you are after. Once this is done if you highlight the keyword and press F1 you can also get specific help on that keyword from the VBE.
 

Forum statistics

Threads
1,141,284
Messages
5,705,510
Members
421,399
Latest member
hjweiss00

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