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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

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