VBA: Query refresh always runs first regardless of where it is in the code.

joeyslaptop

New Member
Joined
Aug 26, 2011
Messages
27
I'm trying to create a macro that does the following:

On theButton was clicked
set theButton style =msoShapeStylePreset12
Run the query
Query refresh completes
set theButton style = msoShapeStylePreset14
end

But, the button doesn't change until after the query has refreshed. I eve tried putting it in a loop with a condition:

Code:
Sub RefreshQueries()
'
' RefreshQueries Macro
' This macro triggers when the button is pushed.  It refreshes the queries that produce the datasets.

Dim Looper As Integer
    Looper = 1
Do
'change the button to yellow.
    Sheets("Stats").Shapes("Rounded Rectangle 1").ShapeStyle = msoShapeStylePreset12
    Looper = 2
    If Looper = 2 Then
'Do query refresh.
    ActiveSheet.Shapes.Range(Array("Rounded Rectangle 1")).Select
    Sheets("Mbrs to Renew").Range("H2").ListObject.QueryTable.Refresh BackgroundQuery:=False
    Looper = 3
    End If
Loop Until Looper = 3
'change the button back to green.
    Sheets("Stats").Shapes("Rounded Rectangle 1").ShapeStyle = msoShapeStylePreset14
End Sub
 
Last edited:
I don't have any problems using FireFox & I have not seen anyone complaining of problems.
It might be worth clearing the cache & cookies, to see if that clears the problem.
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,889
Messages
6,122,097
Members
449,065
Latest member
albertocarrillom

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