[Vba Excel] Query Refresh
Solved
Hello,
I have a little issue with a VBA macro.
Actually, it looks like this:
The big problem is that the query refresh only happens at the end of the script.
I'm doing it like this:
I've tried other things like declaring this refresh in a function and calling it in the macro procedure... Or even using a macro that calls in order the refresh macro and then another macro where the rest of the instructions are, but it doesn't change anything, I still have the same effect.
Do you have any idea?
Thanks.....
I have a little issue with a VBA macro.
Actually, it looks like this:
sub macro() Variable declaration Selecting the first cell Refreshing the query Instructions.... end sub
The big problem is that the query refresh only happens at the end of the script.
I'm doing it like this:
Selection.QueryTable.Refresh
I've tried other things like declaring this refresh in a function and calling it in the macro procedure... Or even using a macro that calls in order the refresh macro and then another macro where the rest of the instructions are, but it doesn't change anything, I still have the same effect.
Do you have any idea?
Thanks.....
Configuration: Windows 2000 Excel 2000
6 answers
-
ModeratorGot it :-)
The query update should not happen in the background:Selection.QueryTable.Refresh BackgroundQuery:=False
-
ModeratorUp :-)
-
ContributorYou mean that you trigger the query refresh but no matter when the code continues to run and doesn't wait for the end of this refresh?
--
COIN! -
ModeratorAbsolutely :-)
Wherever I place the update, it only executes at the end of the macro.....
As a result, all the subsequent instructions perform operations in vain.... -
ContributorAnd is there no wait style instruction possible in VBA?
--
HI! -
ModeratorI just tried with this:
http://www.ilook.fsnet.co.uk/vb/vbsleep.htm
The waiting happens but the request only executes at the end, just like before.....