PC Review


Reply
Thread Tools Rate Thread

Application wait question

 
 
Graeme
Guest
Posts: n/a
 
      11th Apr 2008
I'm having some issues with pausing a macro to allow data to load. I have a
table created from an imported web query, and my macro refreshes the query
and then makes some adjustments to the new data:

Sub NewData()

'Refresh part
Range("e44").Select
Selection.QueryTable.Refresh

'line X

'Adjust part
Range("ColA").Select
Selection.Copy
Range("ColB").Select
Selection.PasteSpecial Paste:=xlPasteValues
Range("ColB").Select
Selection.Replace What:="~*", Replacement:=""
End sub

For line X, I have tried:
Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 10)
and
Application.Wait Now + TimeValue("00:00:10")
and have also made use of:
Public Function Delay()
y = Timer + 10
Do While Timer < y
DoEvents
Loop
End Function

However, when I run the macro, only the Refresh part works even though it
takes 10 seconds to run, but when I run the macro again, the Adjust part then
works. Also, when I step through the data, the pause activates, and
everything seems to work. Any ideas would be appreciated. thanks.

 
Reply With Quote
 
 
 
 
Mark Ivey
Guest
Posts: n/a
 
      11th Apr 2008
Just a thought... still not sure if this will work... but have you tried
separating the macros? Please see example below.


Mark Ivey



Sub NewData()

'Refresh part
Range("e44").Select
Selection.QueryTable.Refresh

' Call the second macro
Second_Macro

End Sub


Sub Second_Macro()

'Adjust part
Range("ColA").Select
Selection.Copy
Range("ColB").Select
Selection.PasteSpecial Paste:=xlPasteValues
Range("ColB").Select
Selection.Replace What:="~*", Replacement:=""
End Sub

 
Reply With Quote
 
Graeme
Guest
Posts: n/a
 
      11th Apr 2008
Mark - thanks for responding. However, I had already tried that, and
unfortunately it didn't work either.

"Mark Ivey" wrote:

> Just a thought... still not sure if this will work... but have you tried
> separating the macros? Please see example below.
>
>
> Mark Ivey
>
>
>
> Sub NewData()
>
> 'Refresh part
> Range("e44").Select
> Selection.QueryTable.Refresh
>
> ' Call the second macro
> Second_Macro
>
> End Sub
>
>
> Sub Second_Macro()
>
> 'Adjust part
> Range("ColA").Select
> Selection.Copy
> Range("ColB").Select
> Selection.PasteSpecial Paste:=xlPasteValues
> Range("ColB").Select
> Selection.Replace What:="~*", Replacement:=""
> End Sub
>

 
Reply With Quote
 
roger
Guest
Posts: n/a
 
      11th Apr 2008
"Graeme" <(E-Mail Removed)> wrote in message
news:4D3EEA5D-5472-4C20-82C0-(E-Mail Removed)...

> I'm having some issues with pausing a macro to allow data to load. I have

a
> table created from an imported web query, and my macro refreshes the query
> and then makes some adjustments to the new data:
>
> Sub NewData()
>
> 'Refresh part
> Range("e44").Select
> Selection.QueryTable.Refresh


Does this work?

Selection.QueryTable.Refresh (False)


--
roger


 
Reply With Quote
 
Graeme
Guest
Posts: n/a
 
      12th Apr 2008
This worked perfectly! Thank you.

"roger" wrote:

> "Graeme" <(E-Mail Removed)> wrote in message
> news:4D3EEA5D-5472-4C20-82C0-(E-Mail Removed)...
>
> > I'm having some issues with pausing a macro to allow data to load. I have

> a
> > table created from an imported web query, and my macro refreshes the query
> > and then makes some adjustments to the new data:
> >
> > Sub NewData()
> >
> > 'Refresh part
> > Range("e44").Select
> > Selection.QueryTable.Refresh

>
> Does this work?
>
> Selection.QueryTable.Refresh (False)
>
>
> --
> roger
>
>
>

 
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
VBA- Application.Wait? Mel Microsoft Powerpoint 2 5th Aug 2011 03:35 PM
application.wait B. Meincke Microsoft Access Form Coding 10 10th Jun 2008 03:19 PM
Re: Application.wait... won't! =?Utf-8?B?anV0bGF1eA==?= Microsoft Excel Programming 0 17th Nov 2006 04:31 AM
application.wait help flowtester Microsoft Excel Programming 10 4th Dec 2005 03:47 PM
"Please wait while Microsoft Outlook Exits" - and wait, and wait, and wait... steŠ Microsoft Outlook Discussion 5 4th Jul 2004 05:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:15 PM.